Fossil SCM

Merged from trunk to pick up work in progress and a bug fix to tester.tcl. Fixed issue introduced by the addition of the insertCsrf and verifyCsrf commands from ci [f8820eff] which broke the test th1-info-commands. Also fixed the dependence on the order of commands output by TH1.

rberteig 2016-02-06 02:03 rberteig-json-test merge
Commit 2de15c8e3b85ccc6f4aa51cf79de75390e2495bf
+212 -137
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
3737
3838
define EXTRA_CFLAGS ""
3939
define EXTRA_LDFLAGS ""
4040
define USE_SYSTEM_SQLITE 0
4141
define USE_LINENOISE 0
42
+
43
+# This procedure is a customized version of "cc-check-function-in-lib",
44
+# that does not modify the LIBS variable. Its use prevents prematurely
45
+# pulling in libraries that will be added later anyhow (e.g. "-ldl").
46
+proc check-function-in-lib {function libs {otherlibs {}}} {
47
+ if {[string length $otherlibs]} {
48
+ msg-checking "Checking for $function in $libs with $otherlibs..."
49
+ } else {
50
+ msg-checking "Checking for $function in $libs..."
51
+ }
52
+ set found 0
53
+ cc-with [list -libs $otherlibs] {
54
+ if {[cctest_function $function]} {
55
+ msg-result "none needed"
56
+ define lib_$function ""
57
+ incr found
58
+ } else {
59
+ foreach lib $libs {
60
+ cc-with [list -libs -l$lib] {
61
+ if {[cctest_function $function]} {
62
+ msg-result -l$lib
63
+ define lib_$function -l$lib
64
+ incr found
65
+ break
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ if {$found} {
72
+ define [feature-define-name $function]
73
+ } else {
74
+ msg-result "no"
75
+ }
76
+ return $found
77
+}
4278
4379
if {![opt-bool internal-sqlite]} {
4480
proc find_internal_sqlite {} {
4581
4682
# On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
5389
# Locate the system SQLite by searching for sqlite3_open(). Then check
5490
# if sqlite3_strglob() can be found as well. If we can find open() but
5591
# not strglob(), then the system SQLite is too old to link against
5692
# fossil.
5793
#
58
- if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
59
- if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
94
+ if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
95
+ if {![check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
6096
user-error "system sqlite3 too old (require >= 3.8.7)"
6197
}
6298
6399
# Success. Update symbols and return.
64100
#
65101
define USE_SYSTEM_SQLITE 1
102
+ define-append LIBS -lsqlite3
66103
define-append LIBS $extralibs
67104
return
68105
}
69106
}
70107
user-error "system sqlite3 not found"
@@ -142,10 +179,152 @@
142179
msg-result "Trying to link statically"
143180
} else {
144181
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
145182
define FOSSIL_DYNAMIC_BUILD
146183
}
184
+
185
+# Helper for OpenSSL checking
186
+proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
187
+ msg-checking "Checking for $msg..."
188
+ set rc 0
189
+ if {[is_mingw]} {
190
+ lappend libs -lgdi32 -lwsock32
191
+ }
192
+ if {[info exists ::zlib_lib]} {
193
+ lappend libs $::zlib_lib
194
+ }
195
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
196
+ if {[cc-check-includes openssl/ssl.h] && \
197
+ [cc-check-functions SSL_new]} {
198
+ incr rc
199
+ }
200
+ }
201
+ if {!$rc && ![is_mingw]} {
202
+ # On some systems, OpenSSL appears to require -ldl to link.
203
+ lappend libs -ldl
204
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
205
+ if {[cc-check-includes openssl/ssl.h] && \
206
+ [cc-check-functions SSL_new]} {
207
+ incr rc
208
+ }
209
+ }
210
+ }
211
+ if {$rc} {
212
+ msg-result "ok"
213
+ return 1
214
+ } else {
215
+ msg-result "no"
216
+ return 0
217
+ }
218
+}
219
+
220
+if {[opt-bool with-miniz]} {
221
+ define FOSSIL_ENABLE_MINIZ 1
222
+ msg-result "Using miniz for compression"
223
+} else {
224
+ # Check for zlib, using the given location if specified
225
+ set zlibpath [opt-val with-zlib]
226
+ if {$zlibpath eq "tree"} {
227
+ set zlibdir [file dirname $autosetup(dir)]/compat/zlib
228
+ if {![file isdirectory $zlibdir]} {
229
+ user-error "The zlib in source tree directory does not exist"
230
+ }
231
+ cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
232
+ define-append EXTRA_CFLAGS -I$zlibdir
233
+ define-append LIBS $zlibdir/libz.a
234
+ set ::zlib_lib $zlibdir/libz.a
235
+ msg-result "Using zlib in source tree"
236
+ } else {
237
+ if {$zlibpath ni {auto ""}} {
238
+ cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
239
+ define-append EXTRA_CFLAGS -I$zlibpath
240
+ define-append EXTRA_LDFLAGS -L$zlibpath
241
+ msg-result "Using zlib from $zlibpath"
242
+ }
243
+ if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
244
+ user-error "zlib not found please install it or specify the location with --with-zlib"
245
+ }
246
+ set ::zlib_lib -lz
247
+ }
248
+}
249
+
250
+set ssldirs [opt-val with-openssl]
251
+if {$ssldirs ne "none"} {
252
+ if {[opt-bool with-miniz]} {
253
+ user-error "The --with-miniz option is incompatible with OpenSSL"
254
+ }
255
+ set found 0
256
+ if {$ssldirs eq "tree"} {
257
+ set ssldir [file dirname $autosetup(dir)]/compat/openssl
258
+ if {![file isdirectory $ssldir]} {
259
+ user-error "The OpenSSL in source tree directory does not exist"
260
+ }
261
+ set msg "ssl in $ssldir"
262
+ set cflags "-I$ssldir/include"
263
+ set ldflags "-L$ssldir"
264
+ set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
265
+ set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
266
+ } else {
267
+ if {$ssldirs in {auto ""}} {
268
+ catch {
269
+ set cflags [exec pkg-config openssl --cflags-only-I]
270
+ set ldflags [exec pkg-config openssl --libs-only-L]
271
+ set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
272
+ } msg
273
+ if {!$found} {
274
+ set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
275
+ }
276
+ }
277
+ if {!$found} {
278
+ foreach dir $ssldirs {
279
+ if {$dir eq ""} {
280
+ set msg "system ssl"
281
+ set cflags ""
282
+ set ldflags ""
283
+ } else {
284
+ set msg "ssl in $dir"
285
+ set cflags "-I$dir/include"
286
+ set ldflags "-L$dir/lib"
287
+ }
288
+ if {[check-for-openssl $msg "$cflags $ldflags"]} {
289
+ incr found
290
+ break
291
+ }
292
+ }
293
+ }
294
+ }
295
+ if {$found} {
296
+ define FOSSIL_ENABLE_SSL
297
+ define-append EXTRA_CFLAGS $cflags
298
+ define-append EXTRA_LDFLAGS $ldflags
299
+ if {[info exists ssllibs]} {
300
+ define-append LIBS $ssllibs
301
+ } else {
302
+ define-append LIBS -lssl -lcrypto
303
+ }
304
+ if {[info exists ::zlib_lib]} {
305
+ define-append LIBS $::zlib_lib
306
+ }
307
+ if {[is_mingw]} {
308
+ define-append LIBS -lgdi32 -lwsock32
309
+ }
310
+ msg-result "HTTPS support enabled"
311
+
312
+ # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
313
+ if {[string match *-darwin* [get-define host]]} {
314
+ if {[cctest -cflags {-Wdeprecated-declarations}]} {
315
+ define-append EXTRA_CFLAGS -Wdeprecated-declarations
316
+ }
317
+ }
318
+ } else {
319
+ user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
320
+ }
321
+} else {
322
+ if {[info exists ::zlib_lib]} {
323
+ define-append LIBS $::zlib_lib
324
+ }
325
+}
147326
148327
set tclpath [opt-val with-tcl]
149328
if {$tclpath ne ""} {
150329
set tclprivatestubs [opt-bool with-tcl-private-stubs]
151330
# Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -210,10 +389,27 @@
210389
if {[cc-check-functions Tcl_CreateInterp]} {
211390
set foundtcl 1
212391
}
213392
}
214393
}
394
+ }
395
+ if {!$foundtcl && ![string match *-lpthread* $libs]} {
396
+ # On some systems, TCL_LIB_SPEC appears to be missing
397
+ # "-lpthread". Try adding it.
398
+ msg-result "Adding \"-lpthread\" and retrying for Tcl..."
399
+ set libs "$libs -lpthread"
400
+ cc-with [list -cflags $cflags -libs $libs] {
401
+ if {$tclstubs} {
402
+ if {[cc-check-functions Tcl_InitStubs]} {
403
+ set foundtcl 1
404
+ }
405
+ } else {
406
+ if {[cc-check-functions Tcl_CreateInterp]} {
407
+ set foundtcl 1
408
+ }
409
+ }
410
+ }
215411
}
216412
if {!$foundtcl} {
217413
if {$tclstubs} {
218414
user-error "Cannot find a usable Tcl stubs library $msg"
219415
} else {
@@ -225,149 +421,28 @@
225421
msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
226422
if {!$tclprivatestubs} {
227423
define-append LIBS $libs
228424
}
229425
define-append EXTRA_CFLAGS $cflags
426
+ if {[info exists zlibpath] && $zlibpath eq "tree"} {
427
+ #
428
+ # NOTE: When using zlib in the source tree, prevent Tcl from
429
+ # pulling in the system one.
430
+ #
431
+ set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
432
+ $tclconfig(TCL_LD_FLAGS)]
433
+ }
434
+ #
435
+ # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
436
+ # be checked for near the bottom of this file.
437
+ #
438
+ set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
439
+ $tclconfig(TCL_LD_FLAGS)]
230440
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
231441
define FOSSIL_ENABLE_TCL
232442
}
233443
234
-# Helper for OpenSSL checking
235
-proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
236
- msg-checking "Checking for $msg..."
237
- set rc 0
238
- if {[is_mingw]} {
239
- lappend libs -lgdi32 -lwsock32
240
- }
241
- if {[info exists ::zlib_for_ssl]} {
242
- lappend libs $::zlib_for_ssl
243
- }
244
- msg-quiet cc-with [list -cflags $cflags -libs $libs] {
245
- if {[cc-check-includes openssl/ssl.h] && \
246
- [cc-check-functions SSL_new]} {
247
- incr rc
248
- }
249
- }
250
- if {!$rc && ![is_mingw]} {
251
- # On some systems, OpenSSL appears to require -ldl to link.
252
- lappend libs -ldl
253
- msg-quiet cc-with [list -cflags $cflags -libs $libs] {
254
- if {[cc-check-includes openssl/ssl.h] && \
255
- [cc-check-functions SSL_new]} {
256
- incr rc
257
- }
258
- }
259
- }
260
- if {$rc} {
261
- msg-result "ok"
262
- return 1
263
- } else {
264
- msg-result "no"
265
- return 0
266
- }
267
-}
268
-
269
-if {[opt-bool with-miniz]} {
270
- define FOSSIL_ENABLE_MINIZ 1
271
- msg-result "Using miniz for compression"
272
-} else {
273
- # Check for zlib, using the given location if specified
274
- set zlibpath [opt-val with-zlib]
275
- if {$zlibpath eq "tree"} {
276
- set zlibdir [file dirname $autosetup(dir)]/compat/zlib
277
- if {![file isdirectory $zlibdir]} {
278
- user-error "The zlib in source tree directory does not exist"
279
- }
280
- cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
281
- define-append EXTRA_CFLAGS -I$zlibdir
282
- define-append LIBS $zlibdir/libz.a
283
- set ::zlib_for_ssl $zlibdir/libz.a
284
- msg-result "Using zlib in source tree"
285
- } else {
286
- if {$zlibpath ni {auto ""}} {
287
- cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
288
- define-append EXTRA_CFLAGS -I$zlibpath
289
- define-append EXTRA_LDFLAGS -L$zlibpath
290
- msg-result "Using zlib from $zlibpath"
291
- }
292
- if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
293
- user-error "zlib not found please install it or specify the location with --with-zlib"
294
- }
295
- set ::zlib_for_ssl -lz
296
- }
297
-}
298
-
299
-set ssldirs [opt-val with-openssl]
300
-if {$ssldirs ne "none"} {
301
- if {[opt-bool with-miniz]} {
302
- user-error "The --with-miniz option is incompatible with OpenSSL"
303
- }
304
- set found 0
305
- if {$ssldirs eq "tree"} {
306
- set ssldir [file dirname $autosetup(dir)]/compat/openssl
307
- if {![file isdirectory $ssldir]} {
308
- user-error "The OpenSSL in source tree directory does not exist"
309
- }
310
- set msg "ssl in $ssldir"
311
- set cflags "-I$ssldir/include"
312
- set ldflags "-L$ssldir"
313
- set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
314
- set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
315
- } else {
316
- if {$ssldirs in {auto ""}} {
317
- catch {
318
- set cflags [exec pkg-config openssl --cflags-only-I]
319
- set ldflags [exec pkg-config openssl --libs-only-L]
320
- set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
321
- } msg
322
- if {!$found} {
323
- set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
324
- }
325
- }
326
- if {!$found} {
327
- foreach dir $ssldirs {
328
- if {$dir eq ""} {
329
- set msg "system ssl"
330
- set cflags ""
331
- set ldflags ""
332
- } else {
333
- set msg "ssl in $dir"
334
- set cflags "-I$dir/include"
335
- set ldflags "-L$dir/lib"
336
- }
337
- if {[check-for-openssl $msg "$cflags $ldflags"]} {
338
- incr found
339
- break
340
- }
341
- }
342
- }
343
- }
344
- if {$found} {
345
- define FOSSIL_ENABLE_SSL
346
- define-append EXTRA_CFLAGS $cflags
347
- define-append EXTRA_LDFLAGS $ldflags
348
- if {[info exists ssllibs]} {
349
- define-append LIBS $ssllibs
350
- } else {
351
- define-append LIBS -lssl -lcrypto
352
- }
353
- if {[is_mingw]} {
354
- define-append LIBS -lgdi32 -lwsock32
355
- }
356
- msg-result "HTTPS support enabled"
357
-
358
- # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
359
- if {[string match *-darwin* [get-define host]]} {
360
- if {[cctest -cflags {-Wdeprecated-declarations}]} {
361
- define-append EXTRA_CFLAGS -Wdeprecated-declarations
362
- }
363
- }
364
- } else {
365
- user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
366
- }
367
-}
368
-
369444
# Network functions require libraries on some systems
370445
cc-check-function-in-lib gethostbyname nsl
371446
if {![cc-check-function-in-lib socket {socket network}]} {
372447
# Last resort, may be Windows
373448
if {[is_mingw]} {
374449
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
37
38 define EXTRA_CFLAGS ""
39 define EXTRA_LDFLAGS ""
40 define USE_SYSTEM_SQLITE 0
41 define USE_LINENOISE 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43 if {![opt-bool internal-sqlite]} {
44 proc find_internal_sqlite {} {
45
46 # On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
53 # Locate the system SQLite by searching for sqlite3_open(). Then check
54 # if sqlite3_strglob() can be found as well. If we can find open() but
55 # not strglob(), then the system SQLite is too old to link against
56 # fossil.
57 #
58 if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
59 if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
60 user-error "system sqlite3 too old (require >= 3.8.7)"
61 }
62
63 # Success. Update symbols and return.
64 #
65 define USE_SYSTEM_SQLITE 1
 
66 define-append LIBS $extralibs
67 return
68 }
69 }
70 user-error "system sqlite3 not found"
@@ -142,10 +179,152 @@
142 msg-result "Trying to link statically"
143 } else {
144 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
145 define FOSSIL_DYNAMIC_BUILD
146 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
148 set tclpath [opt-val with-tcl]
149 if {$tclpath ne ""} {
150 set tclprivatestubs [opt-bool with-tcl-private-stubs]
151 # Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -210,10 +389,27 @@
210 if {[cc-check-functions Tcl_CreateInterp]} {
211 set foundtcl 1
212 }
213 }
214 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215 }
216 if {!$foundtcl} {
217 if {$tclstubs} {
218 user-error "Cannot find a usable Tcl stubs library $msg"
219 } else {
@@ -225,149 +421,28 @@
225 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
226 if {!$tclprivatestubs} {
227 define-append LIBS $libs
228 }
229 define-append EXTRA_CFLAGS $cflags
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
231 define FOSSIL_ENABLE_TCL
232 }
233
234 # Helper for OpenSSL checking
235 proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
236 msg-checking "Checking for $msg..."
237 set rc 0
238 if {[is_mingw]} {
239 lappend libs -lgdi32 -lwsock32
240 }
241 if {[info exists ::zlib_for_ssl]} {
242 lappend libs $::zlib_for_ssl
243 }
244 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
245 if {[cc-check-includes openssl/ssl.h] && \
246 [cc-check-functions SSL_new]} {
247 incr rc
248 }
249 }
250 if {!$rc && ![is_mingw]} {
251 # On some systems, OpenSSL appears to require -ldl to link.
252 lappend libs -ldl
253 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
254 if {[cc-check-includes openssl/ssl.h] && \
255 [cc-check-functions SSL_new]} {
256 incr rc
257 }
258 }
259 }
260 if {$rc} {
261 msg-result "ok"
262 return 1
263 } else {
264 msg-result "no"
265 return 0
266 }
267 }
268
269 if {[opt-bool with-miniz]} {
270 define FOSSIL_ENABLE_MINIZ 1
271 msg-result "Using miniz for compression"
272 } else {
273 # Check for zlib, using the given location if specified
274 set zlibpath [opt-val with-zlib]
275 if {$zlibpath eq "tree"} {
276 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
277 if {![file isdirectory $zlibdir]} {
278 user-error "The zlib in source tree directory does not exist"
279 }
280 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
281 define-append EXTRA_CFLAGS -I$zlibdir
282 define-append LIBS $zlibdir/libz.a
283 set ::zlib_for_ssl $zlibdir/libz.a
284 msg-result "Using zlib in source tree"
285 } else {
286 if {$zlibpath ni {auto ""}} {
287 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
288 define-append EXTRA_CFLAGS -I$zlibpath
289 define-append EXTRA_LDFLAGS -L$zlibpath
290 msg-result "Using zlib from $zlibpath"
291 }
292 if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
293 user-error "zlib not found please install it or specify the location with --with-zlib"
294 }
295 set ::zlib_for_ssl -lz
296 }
297 }
298
299 set ssldirs [opt-val with-openssl]
300 if {$ssldirs ne "none"} {
301 if {[opt-bool with-miniz]} {
302 user-error "The --with-miniz option is incompatible with OpenSSL"
303 }
304 set found 0
305 if {$ssldirs eq "tree"} {
306 set ssldir [file dirname $autosetup(dir)]/compat/openssl
307 if {![file isdirectory $ssldir]} {
308 user-error "The OpenSSL in source tree directory does not exist"
309 }
310 set msg "ssl in $ssldir"
311 set cflags "-I$ssldir/include"
312 set ldflags "-L$ssldir"
313 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
314 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
315 } else {
316 if {$ssldirs in {auto ""}} {
317 catch {
318 set cflags [exec pkg-config openssl --cflags-only-I]
319 set ldflags [exec pkg-config openssl --libs-only-L]
320 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
321 } msg
322 if {!$found} {
323 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
324 }
325 }
326 if {!$found} {
327 foreach dir $ssldirs {
328 if {$dir eq ""} {
329 set msg "system ssl"
330 set cflags ""
331 set ldflags ""
332 } else {
333 set msg "ssl in $dir"
334 set cflags "-I$dir/include"
335 set ldflags "-L$dir/lib"
336 }
337 if {[check-for-openssl $msg "$cflags $ldflags"]} {
338 incr found
339 break
340 }
341 }
342 }
343 }
344 if {$found} {
345 define FOSSIL_ENABLE_SSL
346 define-append EXTRA_CFLAGS $cflags
347 define-append EXTRA_LDFLAGS $ldflags
348 if {[info exists ssllibs]} {
349 define-append LIBS $ssllibs
350 } else {
351 define-append LIBS -lssl -lcrypto
352 }
353 if {[is_mingw]} {
354 define-append LIBS -lgdi32 -lwsock32
355 }
356 msg-result "HTTPS support enabled"
357
358 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
359 if {[string match *-darwin* [get-define host]]} {
360 if {[cctest -cflags {-Wdeprecated-declarations}]} {
361 define-append EXTRA_CFLAGS -Wdeprecated-declarations
362 }
363 }
364 } else {
365 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
366 }
367 }
368
369 # Network functions require libraries on some systems
370 cc-check-function-in-lib gethostbyname nsl
371 if {![cc-check-function-in-lib socket {socket network}]} {
372 # Last resort, may be Windows
373 if {[is_mingw]} {
374
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
37
38 define EXTRA_CFLAGS ""
39 define EXTRA_LDFLAGS ""
40 define USE_SYSTEM_SQLITE 0
41 define USE_LINENOISE 0
42
43 # This procedure is a customized version of "cc-check-function-in-lib",
44 # that does not modify the LIBS variable. Its use prevents prematurely
45 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
46 proc check-function-in-lib {function libs {otherlibs {}}} {
47 if {[string length $otherlibs]} {
48 msg-checking "Checking for $function in $libs with $otherlibs..."
49 } else {
50 msg-checking "Checking for $function in $libs..."
51 }
52 set found 0
53 cc-with [list -libs $otherlibs] {
54 if {[cctest_function $function]} {
55 msg-result "none needed"
56 define lib_$function ""
57 incr found
58 } else {
59 foreach lib $libs {
60 cc-with [list -libs -l$lib] {
61 if {[cctest_function $function]} {
62 msg-result -l$lib
63 define lib_$function -l$lib
64 incr found
65 break
66 }
67 }
68 }
69 }
70 }
71 if {$found} {
72 define [feature-define-name $function]
73 } else {
74 msg-result "no"
75 }
76 return $found
77 }
78
79 if {![opt-bool internal-sqlite]} {
80 proc find_internal_sqlite {} {
81
82 # On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
89 # Locate the system SQLite by searching for sqlite3_open(). Then check
90 # if sqlite3_strglob() can be found as well. If we can find open() but
91 # not strglob(), then the system SQLite is too old to link against
92 # fossil.
93 #
94 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
95 if {![check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
96 user-error "system sqlite3 too old (require >= 3.8.7)"
97 }
98
99 # Success. Update symbols and return.
100 #
101 define USE_SYSTEM_SQLITE 1
102 define-append LIBS -lsqlite3
103 define-append LIBS $extralibs
104 return
105 }
106 }
107 user-error "system sqlite3 not found"
@@ -142,10 +179,152 @@
179 msg-result "Trying to link statically"
180 } else {
181 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
182 define FOSSIL_DYNAMIC_BUILD
183 }
184
185 # Helper for OpenSSL checking
186 proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
187 msg-checking "Checking for $msg..."
188 set rc 0
189 if {[is_mingw]} {
190 lappend libs -lgdi32 -lwsock32
191 }
192 if {[info exists ::zlib_lib]} {
193 lappend libs $::zlib_lib
194 }
195 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
196 if {[cc-check-includes openssl/ssl.h] && \
197 [cc-check-functions SSL_new]} {
198 incr rc
199 }
200 }
201 if {!$rc && ![is_mingw]} {
202 # On some systems, OpenSSL appears to require -ldl to link.
203 lappend libs -ldl
204 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
205 if {[cc-check-includes openssl/ssl.h] && \
206 [cc-check-functions SSL_new]} {
207 incr rc
208 }
209 }
210 }
211 if {$rc} {
212 msg-result "ok"
213 return 1
214 } else {
215 msg-result "no"
216 return 0
217 }
218 }
219
220 if {[opt-bool with-miniz]} {
221 define FOSSIL_ENABLE_MINIZ 1
222 msg-result "Using miniz for compression"
223 } else {
224 # Check for zlib, using the given location if specified
225 set zlibpath [opt-val with-zlib]
226 if {$zlibpath eq "tree"} {
227 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
228 if {![file isdirectory $zlibdir]} {
229 user-error "The zlib in source tree directory does not exist"
230 }
231 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
232 define-append EXTRA_CFLAGS -I$zlibdir
233 define-append LIBS $zlibdir/libz.a
234 set ::zlib_lib $zlibdir/libz.a
235 msg-result "Using zlib in source tree"
236 } else {
237 if {$zlibpath ni {auto ""}} {
238 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
239 define-append EXTRA_CFLAGS -I$zlibpath
240 define-append EXTRA_LDFLAGS -L$zlibpath
241 msg-result "Using zlib from $zlibpath"
242 }
243 if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
244 user-error "zlib not found please install it or specify the location with --with-zlib"
245 }
246 set ::zlib_lib -lz
247 }
248 }
249
250 set ssldirs [opt-val with-openssl]
251 if {$ssldirs ne "none"} {
252 if {[opt-bool with-miniz]} {
253 user-error "The --with-miniz option is incompatible with OpenSSL"
254 }
255 set found 0
256 if {$ssldirs eq "tree"} {
257 set ssldir [file dirname $autosetup(dir)]/compat/openssl
258 if {![file isdirectory $ssldir]} {
259 user-error "The OpenSSL in source tree directory does not exist"
260 }
261 set msg "ssl in $ssldir"
262 set cflags "-I$ssldir/include"
263 set ldflags "-L$ssldir"
264 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
265 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
266 } else {
267 if {$ssldirs in {auto ""}} {
268 catch {
269 set cflags [exec pkg-config openssl --cflags-only-I]
270 set ldflags [exec pkg-config openssl --libs-only-L]
271 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
272 } msg
273 if {!$found} {
274 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
275 }
276 }
277 if {!$found} {
278 foreach dir $ssldirs {
279 if {$dir eq ""} {
280 set msg "system ssl"
281 set cflags ""
282 set ldflags ""
283 } else {
284 set msg "ssl in $dir"
285 set cflags "-I$dir/include"
286 set ldflags "-L$dir/lib"
287 }
288 if {[check-for-openssl $msg "$cflags $ldflags"]} {
289 incr found
290 break
291 }
292 }
293 }
294 }
295 if {$found} {
296 define FOSSIL_ENABLE_SSL
297 define-append EXTRA_CFLAGS $cflags
298 define-append EXTRA_LDFLAGS $ldflags
299 if {[info exists ssllibs]} {
300 define-append LIBS $ssllibs
301 } else {
302 define-append LIBS -lssl -lcrypto
303 }
304 if {[info exists ::zlib_lib]} {
305 define-append LIBS $::zlib_lib
306 }
307 if {[is_mingw]} {
308 define-append LIBS -lgdi32 -lwsock32
309 }
310 msg-result "HTTPS support enabled"
311
312 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
313 if {[string match *-darwin* [get-define host]]} {
314 if {[cctest -cflags {-Wdeprecated-declarations}]} {
315 define-append EXTRA_CFLAGS -Wdeprecated-declarations
316 }
317 }
318 } else {
319 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
320 }
321 } else {
322 if {[info exists ::zlib_lib]} {
323 define-append LIBS $::zlib_lib
324 }
325 }
326
327 set tclpath [opt-val with-tcl]
328 if {$tclpath ne ""} {
329 set tclprivatestubs [opt-bool with-tcl-private-stubs]
330 # Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -210,10 +389,27 @@
389 if {[cc-check-functions Tcl_CreateInterp]} {
390 set foundtcl 1
391 }
392 }
393 }
394 }
395 if {!$foundtcl && ![string match *-lpthread* $libs]} {
396 # On some systems, TCL_LIB_SPEC appears to be missing
397 # "-lpthread". Try adding it.
398 msg-result "Adding \"-lpthread\" and retrying for Tcl..."
399 set libs "$libs -lpthread"
400 cc-with [list -cflags $cflags -libs $libs] {
401 if {$tclstubs} {
402 if {[cc-check-functions Tcl_InitStubs]} {
403 set foundtcl 1
404 }
405 } else {
406 if {[cc-check-functions Tcl_CreateInterp]} {
407 set foundtcl 1
408 }
409 }
410 }
411 }
412 if {!$foundtcl} {
413 if {$tclstubs} {
414 user-error "Cannot find a usable Tcl stubs library $msg"
415 } else {
@@ -225,149 +421,28 @@
421 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
422 if {!$tclprivatestubs} {
423 define-append LIBS $libs
424 }
425 define-append EXTRA_CFLAGS $cflags
426 if {[info exists zlibpath] && $zlibpath eq "tree"} {
427 #
428 # NOTE: When using zlib in the source tree, prevent Tcl from
429 # pulling in the system one.
430 #
431 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
432 $tclconfig(TCL_LD_FLAGS)]
433 }
434 #
435 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
436 # be checked for near the bottom of this file.
437 #
438 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
439 $tclconfig(TCL_LD_FLAGS)]
440 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
441 define FOSSIL_ENABLE_TCL
442 }
443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444 # Network functions require libraries on some systems
445 cc-check-function-in-lib gethostbyname nsl
446 if {![cc-check-function-in-lib socket {socket network}]} {
447 # Last resort, may be Windows
448 if {[is_mingw]} {
449
--- src/json_detail.h
+++ src/json_detail.h
@@ -184,11 +184,11 @@
184184
**
185185
** Now that we can simulate POST in CLI mode, the distinction
186186
** between them has disappeared in most (or all) cases, so 0 is
187187
** the standard value.
188188
*/
189
- char runMode;
189
+ int runMode;
190190
} JsonPageDef;
191191
192192
/*
193193
** Holds common keys used for various JSON API properties.
194194
*/
195195
--- src/json_detail.h
+++ src/json_detail.h
@@ -184,11 +184,11 @@
184 **
185 ** Now that we can simulate POST in CLI mode, the distinction
186 ** between them has disappeared in most (or all) cases, so 0 is
187 ** the standard value.
188 */
189 char runMode;
190 } JsonPageDef;
191
192 /*
193 ** Holds common keys used for various JSON API properties.
194 */
195
--- src/json_detail.h
+++ src/json_detail.h
@@ -184,11 +184,11 @@
184 **
185 ** Now that we can simulate POST in CLI mode, the distinction
186 ** between them has disappeared in most (or all) cases, so 0 is
187 ** the standard value.
188 */
189 int runMode;
190 } JsonPageDef;
191
192 /*
193 ** Holds common keys used for various JSON API properties.
194 */
195
+14 -12
--- src/login.c
+++ src/login.c
@@ -1075,29 +1075,30 @@
10751075
if(NULL==zCap){
10761076
return;
10771077
}
10781078
for(i=0; zCap[i]; i++){
10791079
switch( zCap[i] ){
1080
- case 's': p->Setup = 1; /* Fall thru into Admin */
1080
+ case 's': p->Setup = 1; /* Fall thru into Admin */
10811081
case 'a': p->Admin = p->RdTkt = p->WrTkt = p->Zip =
1082
- p->RdWiki = p->WrWiki = p->NewWiki =
1083
- p->ApndWiki = p->Hyperlink = p->Clone =
1084
- p->NewTkt = p->Password = p->RdAddr =
1085
- p->TktFmt = p->Attach = p->ApndTkt =
1086
- p->ModWiki = p->ModTkt = 1;
1087
- /* Fall thru into Read/Write */
1088
- case 'i': p->Read = p->Write = 1; break;
1082
+ p->RdWiki = p->WrWiki = p->NewWiki =
1083
+ p->ApndWiki = p->Hyperlink = p->Clone =
1084
+ p->NewTkt = p->Password = p->RdAddr =
1085
+ p->TktFmt = p->Attach = p->ApndTkt =
1086
+ p->ModWiki = p->ModTkt = p->Delete =
1087
+ p->Private = 1;
1088
+ /* Fall thru into Read/Write */
1089
+ case 'i': p->Read = p->Write = 1; break;
10891090
case 'o': p->Read = 1; break;
10901091
case 'z': p->Zip = 1; break;
10911092
10921093
case 'd': p->Delete = 1; break;
10931094
case 'h': p->Hyperlink = 1; break;
10941095
case 'g': p->Clone = 1; break;
10951096
case 'p': p->Password = 1; break;
10961097
10971098
case 'j': p->RdWiki = 1; break;
1098
- case 'k': p->WrWiki = p->RdWiki = p->ApndWiki =1; break;
1099
+ case 'k': p->WrWiki = p->RdWiki = p->ApndWiki =1; break;
10991100
case 'm': p->ApndWiki = 1; break;
11001101
case 'f': p->NewWiki = 1; break;
11011102
case 'l': p->ModWiki = 1; break;
11021103
11031104
case 'e': p->RdAddr = 1; break;
@@ -1181,11 +1182,11 @@
11811182
/* case 'v': DEVELOPER */
11821183
case 'w': rc = p->WrTkt; break;
11831184
case 'x': rc = p->Private; break;
11841185
/* case 'y': */
11851186
case 'z': rc = p->Zip; break;
1186
- default: rc = 0; break;
1187
+ default: rc = 0; break;
11871188
}
11881189
}
11891190
return rc;
11901191
}
11911192
@@ -1289,12 +1290,13 @@
12891290
}
12901291
12911292
/*
12921293
** Before using the results of a form, first call this routine to verify
12931294
** that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
1294
-** is missing or is incorrect, that indicates a cross-site scripting attach
1295
-** so emits an error message and abort.
1295
+** is missing or is incorrect, that indicates a cross-site scripting attack.
1296
+** If the event of an attack is detected, an error message is generated and
1297
+** all further processing is aborted.
12961298
*/
12971299
void login_verify_csrf_secret(void){
12981300
if( g.okCsrf ) return;
12991301
if( fossil_strcmp(P("csrf"), g.zCsrfToken)==0 ){
13001302
g.okCsrf = 1;
13011303
--- src/login.c
+++ src/login.c
@@ -1075,29 +1075,30 @@
1075 if(NULL==zCap){
1076 return;
1077 }
1078 for(i=0; zCap[i]; i++){
1079 switch( zCap[i] ){
1080 case 's': p->Setup = 1; /* Fall thru into Admin */
1081 case 'a': p->Admin = p->RdTkt = p->WrTkt = p->Zip =
1082 p->RdWiki = p->WrWiki = p->NewWiki =
1083 p->ApndWiki = p->Hyperlink = p->Clone =
1084 p->NewTkt = p->Password = p->RdAddr =
1085 p->TktFmt = p->Attach = p->ApndTkt =
1086 p->ModWiki = p->ModTkt = 1;
1087 /* Fall thru into Read/Write */
1088 case 'i': p->Read = p->Write = 1; break;
 
1089 case 'o': p->Read = 1; break;
1090 case 'z': p->Zip = 1; break;
1091
1092 case 'd': p->Delete = 1; break;
1093 case 'h': p->Hyperlink = 1; break;
1094 case 'g': p->Clone = 1; break;
1095 case 'p': p->Password = 1; break;
1096
1097 case 'j': p->RdWiki = 1; break;
1098 case 'k': p->WrWiki = p->RdWiki = p->ApndWiki =1; break;
1099 case 'm': p->ApndWiki = 1; break;
1100 case 'f': p->NewWiki = 1; break;
1101 case 'l': p->ModWiki = 1; break;
1102
1103 case 'e': p->RdAddr = 1; break;
@@ -1181,11 +1182,11 @@
1181 /* case 'v': DEVELOPER */
1182 case 'w': rc = p->WrTkt; break;
1183 case 'x': rc = p->Private; break;
1184 /* case 'y': */
1185 case 'z': rc = p->Zip; break;
1186 default: rc = 0; break;
1187 }
1188 }
1189 return rc;
1190 }
1191
@@ -1289,12 +1290,13 @@
1289 }
1290
1291 /*
1292 ** Before using the results of a form, first call this routine to verify
1293 ** that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
1294 ** is missing or is incorrect, that indicates a cross-site scripting attach
1295 ** so emits an error message and abort.
 
1296 */
1297 void login_verify_csrf_secret(void){
1298 if( g.okCsrf ) return;
1299 if( fossil_strcmp(P("csrf"), g.zCsrfToken)==0 ){
1300 g.okCsrf = 1;
1301
--- src/login.c
+++ src/login.c
@@ -1075,29 +1075,30 @@
1075 if(NULL==zCap){
1076 return;
1077 }
1078 for(i=0; zCap[i]; i++){
1079 switch( zCap[i] ){
1080 case 's': p->Setup = 1; /* Fall thru into Admin */
1081 case 'a': p->Admin = p->RdTkt = p->WrTkt = p->Zip =
1082 p->RdWiki = p->WrWiki = p->NewWiki =
1083 p->ApndWiki = p->Hyperlink = p->Clone =
1084 p->NewTkt = p->Password = p->RdAddr =
1085 p->TktFmt = p->Attach = p->ApndTkt =
1086 p->ModWiki = p->ModTkt = p->Delete =
1087 p->Private = 1;
1088 /* Fall thru into Read/Write */
1089 case 'i': p->Read = p->Write = 1; break;
1090 case 'o': p->Read = 1; break;
1091 case 'z': p->Zip = 1; break;
1092
1093 case 'd': p->Delete = 1; break;
1094 case 'h': p->Hyperlink = 1; break;
1095 case 'g': p->Clone = 1; break;
1096 case 'p': p->Password = 1; break;
1097
1098 case 'j': p->RdWiki = 1; break;
1099 case 'k': p->WrWiki = p->RdWiki = p->ApndWiki =1; break;
1100 case 'm': p->ApndWiki = 1; break;
1101 case 'f': p->NewWiki = 1; break;
1102 case 'l': p->ModWiki = 1; break;
1103
1104 case 'e': p->RdAddr = 1; break;
@@ -1181,11 +1182,11 @@
1182 /* case 'v': DEVELOPER */
1183 case 'w': rc = p->WrTkt; break;
1184 case 'x': rc = p->Private; break;
1185 /* case 'y': */
1186 case 'z': rc = p->Zip; break;
1187 default: rc = 0; break;
1188 }
1189 }
1190 return rc;
1191 }
1192
@@ -1289,12 +1290,13 @@
1290 }
1291
1292 /*
1293 ** Before using the results of a form, first call this routine to verify
1294 ** that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
1295 ** is missing or is incorrect, that indicates a cross-site scripting attack.
1296 ** If the event of an attack is detected, an error message is generated and
1297 ** all further processing is aborted.
1298 */
1299 void login_verify_csrf_secret(void){
1300 if( g.okCsrf ) return;
1301 if( fossil_strcmp(P("csrf"), g.zCsrfToken)==0 ){
1302 g.okCsrf = 1;
1303
+119 -69
--- src/main.c
+++ src/main.c
@@ -1009,10 +1009,83 @@
10091009
const char *get_version(){
10101010
static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
10111011
MANIFEST_DATE " UTC";
10121012
return version;
10131013
}
1014
+
1015
+/*
1016
+** This function populates a blob with version information. It is used by
1017
+** the "version" command and "test-version" web page. It assumes the blob
1018
+** passed to it is uninitialized; otherwise, it will leak memory.
1019
+*/
1020
+static void get_version_blob(
1021
+ Blob *pOut, /* Write the manifest here */
1022
+ int bVerbose /* Non-zero for full information. */
1023
+){
1024
+#if defined(FOSSIL_ENABLE_TCL)
1025
+ int rc;
1026
+ const char *zRc;
1027
+#endif
1028
+ blob_zero(pOut);
1029
+ blob_appendf(pOut, "This is fossil version %s\n", get_version());
1030
+ if( !bVerbose ) return;
1031
+ blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
1032
+ __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1033
+ blob_appendf(pOut, "SQLite %s %.30s\n", sqlite3_libversion(),
1034
+ sqlite3_sourceid());
1035
+ blob_appendf(pOut, "Schema version %s\n", AUX_SCHEMA_MAX);
1036
+#if defined(FOSSIL_ENABLE_MINIZ)
1037
+ blob_appendf(pOut, "miniz %s, loaded %s\n", MZ_VERSION, mz_version());
1038
+#else
1039
+ blob_appendf(pOut, "zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1040
+#endif
1041
+#if defined(FOSSIL_ENABLE_SSL)
1042
+ blob_appendf(pOut, "SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1043
+#endif
1044
+#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1045
+ blob_append(pOut, "LEGACY_MV_RM\n", -1);
1046
+#endif
1047
+#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
1048
+ blob_append(pOut, "EXEC_REL_PATHS\n", -1);
1049
+#endif
1050
+#if defined(FOSSIL_ENABLE_TH1_DOCS)
1051
+ blob_append(pOut, "TH1_DOCS\n", -1);
1052
+#endif
1053
+#if defined(FOSSIL_ENABLE_TH1_HOOKS)
1054
+ blob_append(pOut, "TH1_HOOKS\n", -1);
1055
+#endif
1056
+#if defined(FOSSIL_ENABLE_TCL)
1057
+ Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);
1058
+ rc = Th_Eval(g.interp, 0, "tclInvoke info patchlevel", -1);
1059
+ zRc = Th_ReturnCodeName(rc, 0);
1060
+ blob_appendf(pOut, "TCL (Tcl %s, loaded %s: %s)\n",
1061
+ TCL_PATCH_LEVEL, zRc, Th_GetResult(g.interp, 0)
1062
+ );
1063
+#endif
1064
+#if defined(USE_TCL_STUBS)
1065
+ blob_append(pOut, "USE_TCL_STUBS\n", -1);
1066
+#endif
1067
+#if defined(FOSSIL_ENABLE_TCL_STUBS)
1068
+ blob_append(pOut, "TCL_STUBS\n", -1);
1069
+#endif
1070
+#if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS)
1071
+ blob_append(pOut, "TCL_PRIVATE_STUBS\n", -1);
1072
+#endif
1073
+#if defined(FOSSIL_ENABLE_JSON)
1074
+ blob_appendf(pOut, "JSON (API %s)\n", FOSSIL_JSON_API_VERSION);
1075
+#endif
1076
+#if defined(BROKEN_MINGW_CMDLINE)
1077
+ blob_append(pOut, "MBCS_COMMAND_LINE\n", -1);
1078
+#else
1079
+ blob_append(pOut, "UNICODE_COMMAND_LINE\n", -1);
1080
+#endif
1081
+#if defined(FOSSIL_DYNAMIC_BUILD)
1082
+ blob_append(pOut, "DYNAMIC_BUILD\n", -1);
1083
+#else
1084
+ blob_append(pOut, "STATIC_BUILD\n", -1);
1085
+#endif
1086
+}
10141087
10151088
/*
10161089
** This function returns the user-agent string for Fossil, for
10171090
** use in HTTP(S) requests.
10181091
*/
@@ -1019,10 +1092,11 @@
10191092
const char *get_user_agent(){
10201093
static const char version[] = "Fossil/" RELEASE_VERSION " (" MANIFEST_DATE
10211094
" " MANIFEST_VERSION ")";
10221095
return version;
10231096
}
1097
+
10241098
10251099
/*
10261100
** COMMAND: version
10271101
**
10281102
** Usage: %fossil version ?-verbose|-v?
@@ -1031,80 +1105,42 @@
10311105
** If the verbose option is specified, additional details will
10321106
** be output about what optional features this binary was compiled
10331107
** with
10341108
*/
10351109
void version_cmd(void){
1036
- int verboseFlag = 0;
1037
-
1038
- fossil_print("This is fossil version %s\n", get_version());
1039
- verboseFlag = find_option("verbose","v",0)!=0;
1110
+ Blob versionInfo;
1111
+ int verboseFlag = find_option("verbose","v",0)!=0;
10401112
10411113
/* We should be done with options.. */
10421114
verify_all_options();
1043
-
1044
- if(!verboseFlag){
1045
- return;
1046
- }else{
1047
-#if defined(FOSSIL_ENABLE_TCL)
1048
- int rc;
1049
- const char *zRc;
1050
-#endif
1051
- fossil_print("Compiled on %s %s using %s (%d-bit)\n",
1052
- __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1053
- fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid());
1054
- fossil_print("Schema version %s\n", AUX_SCHEMA_MAX);
1055
-#if defined(FOSSIL_ENABLE_MINIZ)
1056
- fossil_print("miniz %s, loaded %s\n", MZ_VERSION, mz_version());
1057
-#else
1058
- fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1059
-#endif
1060
-#if defined(FOSSIL_ENABLE_SSL)
1061
- fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1062
-#endif
1063
-#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1064
- fossil_print("LEGACY_MV_RM\n");
1065
-#endif
1066
-#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
1067
- fossil_print("EXEC_REL_PATHS\n");
1068
-#endif
1069
-#if defined(FOSSIL_ENABLE_TH1_DOCS)
1070
- fossil_print("TH1_DOCS\n");
1071
-#endif
1072
-#if defined(FOSSIL_ENABLE_TH1_HOOKS)
1073
- fossil_print("TH1_HOOKS\n");
1074
-#endif
1075
-#if defined(FOSSIL_ENABLE_TCL)
1076
- Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);
1077
- rc = Th_Eval(g.interp, 0, "tclInvoke info patchlevel", -1);
1078
- zRc = Th_ReturnCodeName(rc, 0);
1079
- fossil_print("TCL (Tcl %s, loaded %s: %s)\n",
1080
- TCL_PATCH_LEVEL, zRc, Th_GetResult(g.interp, 0)
1081
- );
1082
-#endif
1083
-#if defined(USE_TCL_STUBS)
1084
- fossil_print("USE_TCL_STUBS\n");
1085
-#endif
1086
-#if defined(FOSSIL_ENABLE_TCL_STUBS)
1087
- fossil_print("TCL_STUBS\n");
1088
-#endif
1089
-#if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS)
1090
- fossil_print("TCL_PRIVATE_STUBS\n");
1091
-#endif
1092
-#if defined(FOSSIL_ENABLE_JSON)
1093
- fossil_print("JSON (API %s)\n", FOSSIL_JSON_API_VERSION);
1094
-#endif
1095
-#if defined(BROKEN_MINGW_CMDLINE)
1096
- fossil_print("MBCS_COMMAND_LINE\n");
1097
-#else
1098
- fossil_print("UNICODE_COMMAND_LINE\n");
1099
-#endif
1100
-#if defined(FOSSIL_DYNAMIC_BUILD)
1101
- fossil_print("DYNAMIC_BUILD\n");
1102
-#else
1103
- fossil_print("STATIC_BUILD\n");
1104
-#endif
1105
- }
1115
+ get_version_blob(&versionInfo, verboseFlag);
1116
+ fossil_print("%s", blob_str(&versionInfo));
1117
+}
1118
+
1119
+
1120
+/*
1121
+** WEBPAGE: test-version
1122
+**
1123
+** Show the version information for Fossil.
1124
+**
1125
+** Query parameters:
1126
+**
1127
+** verbose Show all available details.
1128
+*/
1129
+void test_version_page(void){
1130
+ Blob versionInfo;
1131
+ int verboseFlag;
1132
+
1133
+ login_check_credentials();
1134
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1135
+ verboseFlag = P("verbose")!=0;
1136
+ style_header("Version Information");
1137
+ get_version_blob(&versionInfo, verboseFlag);
1138
+ @ <blockquote><pre>
1139
+ @ %h(blob_str(&versionInfo))
1140
+ @ </pre></blockquote>
1141
+ style_footer();
11061142
}
11071143
11081144
11091145
/*
11101146
** COMMAND: help
@@ -1361,11 +1397,17 @@
13611397
13621398
if( g.zBaseURL!=0 ) return;
13631399
if( zAltBase ){
13641400
int i, n, c;
13651401
g.zTop = g.zBaseURL = mprintf("%s", zAltBase);
1366
- if( memcmp(g.zTop, "http://", 7)!=0 && memcmp(g.zTop,"https://",8)!=0 ){
1402
+ if( strncmp(g.zTop, "http://", 7)==0 ){
1403
+ /* it is HTTP, replace prefix with HTTPS. */
1404
+ g.zHttpsURL = mprintf("https://%s", &g.zTop[7]);
1405
+ }else if( strncmp(g.zTop, "https://", 8)==0 ){
1406
+ /* it is already HTTPS, use it. */
1407
+ g.zHttpsURL = mprintf("%s", g.zTop);
1408
+ }else{
13671409
fossil_fatal("argument to --baseurl should be 'http://host/path'"
13681410
" or 'https://host/path'");
13691411
}
13701412
for(i=n=0; (c = g.zTop[i])!=0; i++){
13711413
if( c=='/' ){
@@ -2393,11 +2435,13 @@
23932435
** --create Create a new REPOSITORY if it does not already exist
23942436
** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
23952437
** --files GLOBLIST Comma-separated list of glob patterns for static files
23962438
** --localauth enable automatic login for requests from localhost
23972439
** --localhost listen on 127.0.0.1 only (always true for "ui")
2440
+** --https signal a request coming in via https
23982441
** --nojail Drop root privileges but do not enter the chroot jail
2442
+** --nossl signal that no SSL connections are available
23992443
** --notfound URL Redirect
24002444
** -P|--port TCPPORT listen to request on port TCPPORT
24012445
** --th-trace trace TH1 execution (for debugging purposes)
24022446
** --repolist If REPOSITORY is dir, URL "/" lists repos.
24032447
** --scgi Accept SCGI rather than HTTP
@@ -2454,10 +2498,17 @@
24542498
zAltBase = find_option("baseurl", 0, 1);
24552499
fCreate = find_option("create",0,0)!=0;
24562500
if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
24572501
if( zAltBase ){
24582502
set_base_url(zAltBase);
2503
+ }
2504
+ g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2505
+ if( find_option("https",0,0)!=0 ){
2506
+ cgi_replace_parameter("HTTPS","on");
2507
+ }else{
2508
+ /* without --https, defaults to not available. */
2509
+ g.sslNotAvailable = 1;
24592510
}
24602511
if( find_option("localhost", 0, 0)!=0 ){
24612512
flags |= HTTP_SERVER_LOCALHOST;
24622513
}
24632514
@@ -2515,11 +2566,10 @@
25152566
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
25162567
db_close(1);
25172568
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
25182569
fossil_fatal("unable to listen on TCP socket %d", iPort);
25192570
}
2520
- g.sslNotAvailable = 1;
25212571
g.httpIn = stdin;
25222572
g.httpOut = stdout;
25232573
if( g.fHttpTrace || g.fSqlTrace ){
25242574
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
25252575
}
25262576
--- src/main.c
+++ src/main.c
@@ -1009,10 +1009,83 @@
1009 const char *get_version(){
1010 static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
1011 MANIFEST_DATE " UTC";
1012 return version;
1013 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1014
1015 /*
1016 ** This function returns the user-agent string for Fossil, for
1017 ** use in HTTP(S) requests.
1018 */
@@ -1019,10 +1092,11 @@
1019 const char *get_user_agent(){
1020 static const char version[] = "Fossil/" RELEASE_VERSION " (" MANIFEST_DATE
1021 " " MANIFEST_VERSION ")";
1022 return version;
1023 }
 
1024
1025 /*
1026 ** COMMAND: version
1027 **
1028 ** Usage: %fossil version ?-verbose|-v?
@@ -1031,80 +1105,42 @@
1031 ** If the verbose option is specified, additional details will
1032 ** be output about what optional features this binary was compiled
1033 ** with
1034 */
1035 void version_cmd(void){
1036 int verboseFlag = 0;
1037
1038 fossil_print("This is fossil version %s\n", get_version());
1039 verboseFlag = find_option("verbose","v",0)!=0;
1040
1041 /* We should be done with options.. */
1042 verify_all_options();
1043
1044 if(!verboseFlag){
1045 return;
1046 }else{
1047 #if defined(FOSSIL_ENABLE_TCL)
1048 int rc;
1049 const char *zRc;
1050 #endif
1051 fossil_print("Compiled on %s %s using %s (%d-bit)\n",
1052 __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1053 fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid());
1054 fossil_print("Schema version %s\n", AUX_SCHEMA_MAX);
1055 #if defined(FOSSIL_ENABLE_MINIZ)
1056 fossil_print("miniz %s, loaded %s\n", MZ_VERSION, mz_version());
1057 #else
1058 fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1059 #endif
1060 #if defined(FOSSIL_ENABLE_SSL)
1061 fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1062 #endif
1063 #if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1064 fossil_print("LEGACY_MV_RM\n");
1065 #endif
1066 #if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
1067 fossil_print("EXEC_REL_PATHS\n");
1068 #endif
1069 #if defined(FOSSIL_ENABLE_TH1_DOCS)
1070 fossil_print("TH1_DOCS\n");
1071 #endif
1072 #if defined(FOSSIL_ENABLE_TH1_HOOKS)
1073 fossil_print("TH1_HOOKS\n");
1074 #endif
1075 #if defined(FOSSIL_ENABLE_TCL)
1076 Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);
1077 rc = Th_Eval(g.interp, 0, "tclInvoke info patchlevel", -1);
1078 zRc = Th_ReturnCodeName(rc, 0);
1079 fossil_print("TCL (Tcl %s, loaded %s: %s)\n",
1080 TCL_PATCH_LEVEL, zRc, Th_GetResult(g.interp, 0)
1081 );
1082 #endif
1083 #if defined(USE_TCL_STUBS)
1084 fossil_print("USE_TCL_STUBS\n");
1085 #endif
1086 #if defined(FOSSIL_ENABLE_TCL_STUBS)
1087 fossil_print("TCL_STUBS\n");
1088 #endif
1089 #if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS)
1090 fossil_print("TCL_PRIVATE_STUBS\n");
1091 #endif
1092 #if defined(FOSSIL_ENABLE_JSON)
1093 fossil_print("JSON (API %s)\n", FOSSIL_JSON_API_VERSION);
1094 #endif
1095 #if defined(BROKEN_MINGW_CMDLINE)
1096 fossil_print("MBCS_COMMAND_LINE\n");
1097 #else
1098 fossil_print("UNICODE_COMMAND_LINE\n");
1099 #endif
1100 #if defined(FOSSIL_DYNAMIC_BUILD)
1101 fossil_print("DYNAMIC_BUILD\n");
1102 #else
1103 fossil_print("STATIC_BUILD\n");
1104 #endif
1105 }
1106 }
1107
1108
1109 /*
1110 ** COMMAND: help
@@ -1361,11 +1397,17 @@
1361
1362 if( g.zBaseURL!=0 ) return;
1363 if( zAltBase ){
1364 int i, n, c;
1365 g.zTop = g.zBaseURL = mprintf("%s", zAltBase);
1366 if( memcmp(g.zTop, "http://", 7)!=0 && memcmp(g.zTop,"https://",8)!=0 ){
 
 
 
 
 
 
1367 fossil_fatal("argument to --baseurl should be 'http://host/path'"
1368 " or 'https://host/path'");
1369 }
1370 for(i=n=0; (c = g.zTop[i])!=0; i++){
1371 if( c=='/' ){
@@ -2393,11 +2435,13 @@
2393 ** --create Create a new REPOSITORY if it does not already exist
2394 ** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
2395 ** --files GLOBLIST Comma-separated list of glob patterns for static files
2396 ** --localauth enable automatic login for requests from localhost
2397 ** --localhost listen on 127.0.0.1 only (always true for "ui")
 
2398 ** --nojail Drop root privileges but do not enter the chroot jail
 
2399 ** --notfound URL Redirect
2400 ** -P|--port TCPPORT listen to request on port TCPPORT
2401 ** --th-trace trace TH1 execution (for debugging purposes)
2402 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2403 ** --scgi Accept SCGI rather than HTTP
@@ -2454,10 +2498,17 @@
2454 zAltBase = find_option("baseurl", 0, 1);
2455 fCreate = find_option("create",0,0)!=0;
2456 if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
2457 if( zAltBase ){
2458 set_base_url(zAltBase);
 
 
 
 
 
 
 
2459 }
2460 if( find_option("localhost", 0, 0)!=0 ){
2461 flags |= HTTP_SERVER_LOCALHOST;
2462 }
2463
@@ -2515,11 +2566,10 @@
2515 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2516 db_close(1);
2517 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2518 fossil_fatal("unable to listen on TCP socket %d", iPort);
2519 }
2520 g.sslNotAvailable = 1;
2521 g.httpIn = stdin;
2522 g.httpOut = stdout;
2523 if( g.fHttpTrace || g.fSqlTrace ){
2524 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2525 }
2526
--- src/main.c
+++ src/main.c
@@ -1009,10 +1009,83 @@
1009 const char *get_version(){
1010 static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
1011 MANIFEST_DATE " UTC";
1012 return version;
1013 }
1014
1015 /*
1016 ** This function populates a blob with version information. It is used by
1017 ** the "version" command and "test-version" web page. It assumes the blob
1018 ** passed to it is uninitialized; otherwise, it will leak memory.
1019 */
1020 static void get_version_blob(
1021 Blob *pOut, /* Write the manifest here */
1022 int bVerbose /* Non-zero for full information. */
1023 ){
1024 #if defined(FOSSIL_ENABLE_TCL)
1025 int rc;
1026 const char *zRc;
1027 #endif
1028 blob_zero(pOut);
1029 blob_appendf(pOut, "This is fossil version %s\n", get_version());
1030 if( !bVerbose ) return;
1031 blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
1032 __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1033 blob_appendf(pOut, "SQLite %s %.30s\n", sqlite3_libversion(),
1034 sqlite3_sourceid());
1035 blob_appendf(pOut, "Schema version %s\n", AUX_SCHEMA_MAX);
1036 #if defined(FOSSIL_ENABLE_MINIZ)
1037 blob_appendf(pOut, "miniz %s, loaded %s\n", MZ_VERSION, mz_version());
1038 #else
1039 blob_appendf(pOut, "zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1040 #endif
1041 #if defined(FOSSIL_ENABLE_SSL)
1042 blob_appendf(pOut, "SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1043 #endif
1044 #if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1045 blob_append(pOut, "LEGACY_MV_RM\n", -1);
1046 #endif
1047 #if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
1048 blob_append(pOut, "EXEC_REL_PATHS\n", -1);
1049 #endif
1050 #if defined(FOSSIL_ENABLE_TH1_DOCS)
1051 blob_append(pOut, "TH1_DOCS\n", -1);
1052 #endif
1053 #if defined(FOSSIL_ENABLE_TH1_HOOKS)
1054 blob_append(pOut, "TH1_HOOKS\n", -1);
1055 #endif
1056 #if defined(FOSSIL_ENABLE_TCL)
1057 Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);
1058 rc = Th_Eval(g.interp, 0, "tclInvoke info patchlevel", -1);
1059 zRc = Th_ReturnCodeName(rc, 0);
1060 blob_appendf(pOut, "TCL (Tcl %s, loaded %s: %s)\n",
1061 TCL_PATCH_LEVEL, zRc, Th_GetResult(g.interp, 0)
1062 );
1063 #endif
1064 #if defined(USE_TCL_STUBS)
1065 blob_append(pOut, "USE_TCL_STUBS\n", -1);
1066 #endif
1067 #if defined(FOSSIL_ENABLE_TCL_STUBS)
1068 blob_append(pOut, "TCL_STUBS\n", -1);
1069 #endif
1070 #if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS)
1071 blob_append(pOut, "TCL_PRIVATE_STUBS\n", -1);
1072 #endif
1073 #if defined(FOSSIL_ENABLE_JSON)
1074 blob_appendf(pOut, "JSON (API %s)\n", FOSSIL_JSON_API_VERSION);
1075 #endif
1076 #if defined(BROKEN_MINGW_CMDLINE)
1077 blob_append(pOut, "MBCS_COMMAND_LINE\n", -1);
1078 #else
1079 blob_append(pOut, "UNICODE_COMMAND_LINE\n", -1);
1080 #endif
1081 #if defined(FOSSIL_DYNAMIC_BUILD)
1082 blob_append(pOut, "DYNAMIC_BUILD\n", -1);
1083 #else
1084 blob_append(pOut, "STATIC_BUILD\n", -1);
1085 #endif
1086 }
1087
1088 /*
1089 ** This function returns the user-agent string for Fossil, for
1090 ** use in HTTP(S) requests.
1091 */
@@ -1019,10 +1092,11 @@
1092 const char *get_user_agent(){
1093 static const char version[] = "Fossil/" RELEASE_VERSION " (" MANIFEST_DATE
1094 " " MANIFEST_VERSION ")";
1095 return version;
1096 }
1097
1098
1099 /*
1100 ** COMMAND: version
1101 **
1102 ** Usage: %fossil version ?-verbose|-v?
@@ -1031,80 +1105,42 @@
1105 ** If the verbose option is specified, additional details will
1106 ** be output about what optional features this binary was compiled
1107 ** with
1108 */
1109 void version_cmd(void){
1110 Blob versionInfo;
1111 int verboseFlag = find_option("verbose","v",0)!=0;
 
 
1112
1113 /* We should be done with options.. */
1114 verify_all_options();
1115 get_version_blob(&versionInfo, verboseFlag);
1116 fossil_print("%s", blob_str(&versionInfo));
1117 }
1118
1119
1120 /*
1121 ** WEBPAGE: test-version
1122 **
1123 ** Show the version information for Fossil.
1124 **
1125 ** Query parameters:
1126 **
1127 ** verbose Show all available details.
1128 */
1129 void test_version_page(void){
1130 Blob versionInfo;
1131 int verboseFlag;
1132
1133 login_check_credentials();
1134 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1135 verboseFlag = P("verbose")!=0;
1136 style_header("Version Information");
1137 get_version_blob(&versionInfo, verboseFlag);
1138 @ <blockquote><pre>
1139 @ %h(blob_str(&versionInfo))
1140 @ </pre></blockquote>
1141 style_footer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1142 }
1143
1144
1145 /*
1146 ** COMMAND: help
@@ -1361,11 +1397,17 @@
1397
1398 if( g.zBaseURL!=0 ) return;
1399 if( zAltBase ){
1400 int i, n, c;
1401 g.zTop = g.zBaseURL = mprintf("%s", zAltBase);
1402 if( strncmp(g.zTop, "http://", 7)==0 ){
1403 /* it is HTTP, replace prefix with HTTPS. */
1404 g.zHttpsURL = mprintf("https://%s", &g.zTop[7]);
1405 }else if( strncmp(g.zTop, "https://", 8)==0 ){
1406 /* it is already HTTPS, use it. */
1407 g.zHttpsURL = mprintf("%s", g.zTop);
1408 }else{
1409 fossil_fatal("argument to --baseurl should be 'http://host/path'"
1410 " or 'https://host/path'");
1411 }
1412 for(i=n=0; (c = g.zTop[i])!=0; i++){
1413 if( c=='/' ){
@@ -2393,11 +2435,13 @@
2435 ** --create Create a new REPOSITORY if it does not already exist
2436 ** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
2437 ** --files GLOBLIST Comma-separated list of glob patterns for static files
2438 ** --localauth enable automatic login for requests from localhost
2439 ** --localhost listen on 127.0.0.1 only (always true for "ui")
2440 ** --https signal a request coming in via https
2441 ** --nojail Drop root privileges but do not enter the chroot jail
2442 ** --nossl signal that no SSL connections are available
2443 ** --notfound URL Redirect
2444 ** -P|--port TCPPORT listen to request on port TCPPORT
2445 ** --th-trace trace TH1 execution (for debugging purposes)
2446 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2447 ** --scgi Accept SCGI rather than HTTP
@@ -2454,10 +2498,17 @@
2498 zAltBase = find_option("baseurl", 0, 1);
2499 fCreate = find_option("create",0,0)!=0;
2500 if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
2501 if( zAltBase ){
2502 set_base_url(zAltBase);
2503 }
2504 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2505 if( find_option("https",0,0)!=0 ){
2506 cgi_replace_parameter("HTTPS","on");
2507 }else{
2508 /* without --https, defaults to not available. */
2509 g.sslNotAvailable = 1;
2510 }
2511 if( find_option("localhost", 0, 0)!=0 ){
2512 flags |= HTTP_SERVER_LOCALHOST;
2513 }
2514
@@ -2515,11 +2566,10 @@
2566 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2567 db_close(1);
2568 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2569 fossil_fatal("unable to listen on TCP socket %d", iPort);
2570 }
 
2571 g.httpIn = stdin;
2572 g.httpOut = stdout;
2573 if( g.fHttpTrace || g.fSqlTrace ){
2574 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2575 }
2576
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -617,11 +617,11 @@
617617
#### The directories where the OpenSSL include and library files are located.
618618
# The recommended usage here is to use the Sysinternals junction tool
619619
# to create a hard link between an "openssl-1.x" sub-directory of the
620620
# Fossil source code directory and the target OpenSSL source directory.
621621
#
622
-OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
622
+OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
623623
OPENSSLINCDIR = $(OPENSSLDIR)/include
624624
OPENSSLLIBDIR = $(OPENSSLDIR)
625625
626626
#### Either the directory where the Tcl library is installed or the Tcl
627627
# source code directory resides (depending on the value of the macro
@@ -1406,11 +1406,11 @@
14061406
!ifndef FOSSIL_ENABLE_WINXP
14071407
FOSSIL_ENABLE_WINXP = 0
14081408
!endif
14091409
14101410
!if $(FOSSIL_ENABLE_SSL)!=0
1411
-SSLDIR = $(B)\compat\openssl-1.0.2e
1411
+SSLDIR = $(B)\compat\openssl-1.0.2f
14121412
SSLINCDIR = $(SSLDIR)\inc32
14131413
!if $(FOSSIL_DYNAMIC_BUILD)!=0
14141414
SSLLIBDIR = $(SSLDIR)\out32dll
14151415
!else
14161416
SSLLIBDIR = $(SSLDIR)\out32
14171417
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -617,11 +617,11 @@
617 #### The directories where the OpenSSL include and library files are located.
618 # The recommended usage here is to use the Sysinternals junction tool
619 # to create a hard link between an "openssl-1.x" sub-directory of the
620 # Fossil source code directory and the target OpenSSL source directory.
621 #
622 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
623 OPENSSLINCDIR = $(OPENSSLDIR)/include
624 OPENSSLLIBDIR = $(OPENSSLDIR)
625
626 #### Either the directory where the Tcl library is installed or the Tcl
627 # source code directory resides (depending on the value of the macro
@@ -1406,11 +1406,11 @@
1406 !ifndef FOSSIL_ENABLE_WINXP
1407 FOSSIL_ENABLE_WINXP = 0
1408 !endif
1409
1410 !if $(FOSSIL_ENABLE_SSL)!=0
1411 SSLDIR = $(B)\compat\openssl-1.0.2e
1412 SSLINCDIR = $(SSLDIR)\inc32
1413 !if $(FOSSIL_DYNAMIC_BUILD)!=0
1414 SSLLIBDIR = $(SSLDIR)\out32dll
1415 !else
1416 SSLLIBDIR = $(SSLDIR)\out32
1417
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -617,11 +617,11 @@
617 #### The directories where the OpenSSL include and library files are located.
618 # The recommended usage here is to use the Sysinternals junction tool
619 # to create a hard link between an "openssl-1.x" sub-directory of the
620 # Fossil source code directory and the target OpenSSL source directory.
621 #
622 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
623 OPENSSLINCDIR = $(OPENSSLDIR)/include
624 OPENSSLLIBDIR = $(OPENSSLDIR)
625
626 #### Either the directory where the Tcl library is installed or the Tcl
627 # source code directory resides (depending on the value of the macro
@@ -1406,11 +1406,11 @@
1406 !ifndef FOSSIL_ENABLE_WINXP
1407 FOSSIL_ENABLE_WINXP = 0
1408 !endif
1409
1410 !if $(FOSSIL_ENABLE_SSL)!=0
1411 SSLDIR = $(B)\compat\openssl-1.0.2f
1412 SSLINCDIR = $(SSLDIR)\inc32
1413 !if $(FOSSIL_DYNAMIC_BUILD)!=0
1414 SSLLIBDIR = $(SSLDIR)\out32dll
1415 !else
1416 SSLLIBDIR = $(SSLDIR)\out32
1417
+2 -2
--- src/th_lang.c
+++ src/th_lang.c
@@ -990,11 +990,11 @@
990990
}
991991
992992
/*
993993
** TH Syntax:
994994
**
995
-** array names
995
+** array names VARNAME
996996
*/
997997
static int array_names_command(
998998
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
999999
){
10001000
int rc;
@@ -1014,11 +1014,11 @@
10141014
}
10151015
10161016
/*
10171017
** TH Syntax:
10181018
**
1019
-** unset VAR
1019
+** unset VARNAME
10201020
*/
10211021
static int unset_command(
10221022
Th_Interp *interp,
10231023
void *ctx,
10241024
int argc,
10251025
--- src/th_lang.c
+++ src/th_lang.c
@@ -990,11 +990,11 @@
990 }
991
992 /*
993 ** TH Syntax:
994 **
995 ** array names
996 */
997 static int array_names_command(
998 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
999 ){
1000 int rc;
@@ -1014,11 +1014,11 @@
1014 }
1015
1016 /*
1017 ** TH Syntax:
1018 **
1019 ** unset VAR
1020 */
1021 static int unset_command(
1022 Th_Interp *interp,
1023 void *ctx,
1024 int argc,
1025
--- src/th_lang.c
+++ src/th_lang.c
@@ -990,11 +990,11 @@
990 }
991
992 /*
993 ** TH Syntax:
994 **
995 ** array names VARNAME
996 */
997 static int array_names_command(
998 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
999 ){
1000 int rc;
@@ -1014,11 +1014,11 @@
1014 }
1015
1016 /*
1017 ** TH Syntax:
1018 **
1019 ** unset VARNAME
1020 */
1021 static int unset_command(
1022 Th_Interp *interp,
1023 void *ctx,
1024 int argc,
1025
+115 -3
--- src/th_main.c
+++ src/th_main.c
@@ -430,10 +430,74 @@
430430
return Th_WrongNumArgs(interp, "puts STRING");
431431
}
432432
sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
433433
return TH_OK;
434434
}
435
+
436
+/*
437
+** TH1 command: redirect URL
438
+**
439
+** Issues an HTTP redirect (302) to the specified URL and then exits the
440
+** process.
441
+*/
442
+static int redirectCmd(
443
+ Th_Interp *interp,
444
+ void *p,
445
+ int argc,
446
+ const char **argv,
447
+ int *argl
448
+){
449
+ if( argc!=2 ){
450
+ return Th_WrongNumArgs(interp, "redirect URL");
451
+ }
452
+ cgi_redirect(argv[1]);
453
+ Th_SetResult(interp, argv[1], argl[1]); /* NOT REACHED */
454
+ return TH_OK;
455
+}
456
+
457
+/*
458
+** TH1 command: insertCsrf
459
+**
460
+** While rendering a form, call this command to add the Anti-CSRF token
461
+** as a hidden element of the form.
462
+*/
463
+static int insertCsrfCmd(
464
+ Th_Interp *interp,
465
+ void *p,
466
+ int argc,
467
+ const char **argv,
468
+ int *argl
469
+){
470
+ if( argc!=1 ){
471
+ return Th_WrongNumArgs(interp, "insertCsrf");
472
+ }
473
+ login_insert_csrf_secret();
474
+ return TH_OK;
475
+}
476
+
477
+/*
478
+** TH1 command: verifyCsrf
479
+**
480
+** Before using the results of a form, first call this command to verify
481
+** that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
482
+** is missing or is incorrect, that indicates a cross-site scripting attack.
483
+** If the event of an attack is detected, an error message is generated and
484
+** all further processing is aborted.
485
+*/
486
+static int verifyCsrfCmd(
487
+ Th_Interp *interp,
488
+ void *p,
489
+ int argc,
490
+ const char **argv,
491
+ int *argl
492
+){
493
+ if( argc!=1 ){
494
+ return Th_WrongNumArgs(interp, "verifyCsrf");
495
+ }
496
+ login_verify_csrf_secret();
497
+ return TH_OK;
498
+}
435499
436500
/*
437501
** TH1 command: markdown STRING
438502
**
439503
** Renders the input string as markdown. The result is a two-element list.
@@ -1767,15 +1831,17 @@
17671831
{"hascap", hascapCmd, (void*)&zeroInt},
17681832
{"hasfeature", hasfeatureCmd, 0},
17691833
{"html", putsCmd, (void*)&aFlags[0]},
17701834
{"htmlize", htmlizeCmd, 0},
17711835
{"http", httpCmd, 0},
1836
+ {"insertCsrf", insertCsrfCmd, 0},
17721837
{"linecount", linecntCmd, 0},
17731838
{"markdown", markdownCmd, 0},
17741839
{"puts", putsCmd, (void*)&aFlags[1]},
17751840
{"query", queryCmd, 0},
17761841
{"randhex", randhexCmd, 0},
1842
+ {"redirect", redirectCmd, 0},
17771843
{"regexp", regexpCmd, 0},
17781844
{"reinitialize", reinitializeCmd, 0},
17791845
{"render", renderCmd, 0},
17801846
{"repository", repositoryCmd, 0},
17811847
{"searchable", searchableCmd, 0},
@@ -1785,10 +1851,11 @@
17851851
{"styleFooter", styleFooterCmd, 0},
17861852
{"tclReady", tclReadyCmd, 0},
17871853
{"trace", traceCmd, 0},
17881854
{"stime", stimeCmd, 0},
17891855
{"utime", utimeCmd, 0},
1856
+ {"verifyCsrf", verifyCsrfCmd, 0},
17901857
{"wiki", wikiCmd, (void*)&aFlags[0]},
17911858
{0, 0, 0}
17921859
};
17931860
if( g.thTrace ){
17941861
Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
@@ -2291,11 +2358,11 @@
22912358
** --http Include an HTTP response header in the output
22922359
** --open-config Open the configuration database
22932360
** --th-trace Trace TH1 execution (for debugging purposes)
22942361
*/
22952362
void test_th_render(void){
2296
- int forceCgi = 0, fullHttpReply = 0;
2363
+ int forceCgi, fullHttpReply;
22972364
Blob in;
22982365
Th_InitTraceLog();
22992366
forceCgi = find_option("cgi", 0, 0)!=0;
23002367
fullHttpReply = find_option("http", 0, 0)!=0;
23012368
if( fullHttpReply ) forceCgi = 1;
@@ -2318,11 +2385,11 @@
23182385
** COMMAND: test-th-eval
23192386
**
23202387
** Usage: %fossil test-th-eval SCRIPT
23212388
**
23222389
** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2323
-** script, evaluate it, and show the results on standard output.
2390
+** script and show the results on standard output.
23242391
**
23252392
** Options:
23262393
**
23272394
** --cgi Include a CGI response header in the output
23282395
** --http Include an HTTP response header in the output
@@ -2339,15 +2406,59 @@
23392406
if( fullHttpReply ) forceCgi = 1;
23402407
if( forceCgi ) Th_ForceCgi(fullHttpReply);
23412408
if( find_option("open-config", 0, 0)!=0 ){
23422409
Th_OpenConfig(1);
23432410
}
2411
+ verify_all_options();
23442412
if( g.argc!=3 ){
23452413
usage("script");
23462414
}
23472415
Th_FossilInit(TH_INIT_DEFAULT);
23482416
rc = Th_Eval(g.interp, 0, g.argv[2], -1);
2417
+ zRc = Th_ReturnCodeName(rc, 1);
2418
+ fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
2419
+ Th_PrintTraceLog();
2420
+ if( forceCgi ) cgi_reply();
2421
+}
2422
+
2423
+/*
2424
+** COMMAND: test-th-source
2425
+**
2426
+** Usage: %fossil test-th-source FILE
2427
+**
2428
+** Evaluate the contents of the file named "FILE" as if it were a header
2429
+** or footer or ticket rendering script and show the results on standard
2430
+** output.
2431
+**
2432
+** Options:
2433
+**
2434
+** --cgi Include a CGI response header in the output
2435
+** --http Include an HTTP response header in the output
2436
+** --open-config Open the configuration database
2437
+** --th-trace Trace TH1 execution (for debugging purposes)
2438
+*/
2439
+void test_th_source(void){
2440
+ int rc;
2441
+ const char *zRc;
2442
+ int forceCgi, fullHttpReply;
2443
+ Blob in;
2444
+ Th_InitTraceLog();
2445
+ forceCgi = find_option("cgi", 0, 0)!=0;
2446
+ fullHttpReply = find_option("http", 0, 0)!=0;
2447
+ if( fullHttpReply ) forceCgi = 1;
2448
+ if( forceCgi ) Th_ForceCgi(fullHttpReply);
2449
+ if( find_option("open-config", 0, 0)!=0 ){
2450
+ Th_OpenConfig(1);
2451
+ }
2452
+ verify_all_options();
2453
+ if( g.argc!=3 ){
2454
+ usage("file");
2455
+ }
2456
+ blob_zero(&in);
2457
+ blob_read_from_file(&in, g.argv[2]);
2458
+ Th_FossilInit(TH_INIT_DEFAULT);
2459
+ rc = Th_Eval(g.interp, 0, blob_str(&in), -1);
23492460
zRc = Th_ReturnCodeName(rc, 1);
23502461
fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
23512462
Th_PrintTraceLog();
23522463
if( forceCgi ) cgi_reply();
23532464
}
@@ -2356,11 +2467,11 @@
23562467
/*
23572468
** COMMAND: test-th-hook
23582469
**
23592470
** Usage: %fossil test-th-hook TYPE NAME FLAGS
23602471
**
2361
-** Executes the TH1 script configured for the pre-operation (i.e. a command
2472
+** Evaluates the TH1 script configured for the pre-operation (i.e. a command
23622473
** or web page) "hook" or post-operation "notification". The results of the
23632474
** script evaluation, if any, will be printed to the standard output channel.
23642475
** The NAME argument must be the name of a command or web page; however, it
23652476
** does not necessarily have to be a command or web page that is normally
23662477
** recognized by Fossil. The FLAGS argument will be used to set the value
@@ -2397,10 +2508,11 @@
23972508
Th_InitTraceLog();
23982509
forceCgi = find_option("cgi", 0, 0)!=0;
23992510
fullHttpReply = find_option("http", 0, 0)!=0;
24002511
if( fullHttpReply ) forceCgi = 1;
24012512
if( forceCgi ) Th_ForceCgi(fullHttpReply);
2513
+ verify_all_options();
24022514
if( g.argc<5 ){
24032515
usage("TYPE NAME FLAGS");
24042516
}
24052517
if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
24062518
rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
24072519
--- src/th_main.c
+++ src/th_main.c
@@ -430,10 +430,74 @@
430 return Th_WrongNumArgs(interp, "puts STRING");
431 }
432 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
433 return TH_OK;
434 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
436 /*
437 ** TH1 command: markdown STRING
438 **
439 ** Renders the input string as markdown. The result is a two-element list.
@@ -1767,15 +1831,17 @@
1767 {"hascap", hascapCmd, (void*)&zeroInt},
1768 {"hasfeature", hasfeatureCmd, 0},
1769 {"html", putsCmd, (void*)&aFlags[0]},
1770 {"htmlize", htmlizeCmd, 0},
1771 {"http", httpCmd, 0},
 
1772 {"linecount", linecntCmd, 0},
1773 {"markdown", markdownCmd, 0},
1774 {"puts", putsCmd, (void*)&aFlags[1]},
1775 {"query", queryCmd, 0},
1776 {"randhex", randhexCmd, 0},
 
1777 {"regexp", regexpCmd, 0},
1778 {"reinitialize", reinitializeCmd, 0},
1779 {"render", renderCmd, 0},
1780 {"repository", repositoryCmd, 0},
1781 {"searchable", searchableCmd, 0},
@@ -1785,10 +1851,11 @@
1785 {"styleFooter", styleFooterCmd, 0},
1786 {"tclReady", tclReadyCmd, 0},
1787 {"trace", traceCmd, 0},
1788 {"stime", stimeCmd, 0},
1789 {"utime", utimeCmd, 0},
 
1790 {"wiki", wikiCmd, (void*)&aFlags[0]},
1791 {0, 0, 0}
1792 };
1793 if( g.thTrace ){
1794 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
@@ -2291,11 +2358,11 @@
2291 ** --http Include an HTTP response header in the output
2292 ** --open-config Open the configuration database
2293 ** --th-trace Trace TH1 execution (for debugging purposes)
2294 */
2295 void test_th_render(void){
2296 int forceCgi = 0, fullHttpReply = 0;
2297 Blob in;
2298 Th_InitTraceLog();
2299 forceCgi = find_option("cgi", 0, 0)!=0;
2300 fullHttpReply = find_option("http", 0, 0)!=0;
2301 if( fullHttpReply ) forceCgi = 1;
@@ -2318,11 +2385,11 @@
2318 ** COMMAND: test-th-eval
2319 **
2320 ** Usage: %fossil test-th-eval SCRIPT
2321 **
2322 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2323 ** script, evaluate it, and show the results on standard output.
2324 **
2325 ** Options:
2326 **
2327 ** --cgi Include a CGI response header in the output
2328 ** --http Include an HTTP response header in the output
@@ -2339,15 +2406,59 @@
2339 if( fullHttpReply ) forceCgi = 1;
2340 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2341 if( find_option("open-config", 0, 0)!=0 ){
2342 Th_OpenConfig(1);
2343 }
 
2344 if( g.argc!=3 ){
2345 usage("script");
2346 }
2347 Th_FossilInit(TH_INIT_DEFAULT);
2348 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2349 zRc = Th_ReturnCodeName(rc, 1);
2350 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
2351 Th_PrintTraceLog();
2352 if( forceCgi ) cgi_reply();
2353 }
@@ -2356,11 +2467,11 @@
2356 /*
2357 ** COMMAND: test-th-hook
2358 **
2359 ** Usage: %fossil test-th-hook TYPE NAME FLAGS
2360 **
2361 ** Executes the TH1 script configured for the pre-operation (i.e. a command
2362 ** or web page) "hook" or post-operation "notification". The results of the
2363 ** script evaluation, if any, will be printed to the standard output channel.
2364 ** The NAME argument must be the name of a command or web page; however, it
2365 ** does not necessarily have to be a command or web page that is normally
2366 ** recognized by Fossil. The FLAGS argument will be used to set the value
@@ -2397,10 +2508,11 @@
2397 Th_InitTraceLog();
2398 forceCgi = find_option("cgi", 0, 0)!=0;
2399 fullHttpReply = find_option("http", 0, 0)!=0;
2400 if( fullHttpReply ) forceCgi = 1;
2401 if( forceCgi ) Th_ForceCgi(fullHttpReply);
 
2402 if( g.argc<5 ){
2403 usage("TYPE NAME FLAGS");
2404 }
2405 if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
2406 rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
2407
--- src/th_main.c
+++ src/th_main.c
@@ -430,10 +430,74 @@
430 return Th_WrongNumArgs(interp, "puts STRING");
431 }
432 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
433 return TH_OK;
434 }
435
436 /*
437 ** TH1 command: redirect URL
438 **
439 ** Issues an HTTP redirect (302) to the specified URL and then exits the
440 ** process.
441 */
442 static int redirectCmd(
443 Th_Interp *interp,
444 void *p,
445 int argc,
446 const char **argv,
447 int *argl
448 ){
449 if( argc!=2 ){
450 return Th_WrongNumArgs(interp, "redirect URL");
451 }
452 cgi_redirect(argv[1]);
453 Th_SetResult(interp, argv[1], argl[1]); /* NOT REACHED */
454 return TH_OK;
455 }
456
457 /*
458 ** TH1 command: insertCsrf
459 **
460 ** While rendering a form, call this command to add the Anti-CSRF token
461 ** as a hidden element of the form.
462 */
463 static int insertCsrfCmd(
464 Th_Interp *interp,
465 void *p,
466 int argc,
467 const char **argv,
468 int *argl
469 ){
470 if( argc!=1 ){
471 return Th_WrongNumArgs(interp, "insertCsrf");
472 }
473 login_insert_csrf_secret();
474 return TH_OK;
475 }
476
477 /*
478 ** TH1 command: verifyCsrf
479 **
480 ** Before using the results of a form, first call this command to verify
481 ** that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
482 ** is missing or is incorrect, that indicates a cross-site scripting attack.
483 ** If the event of an attack is detected, an error message is generated and
484 ** all further processing is aborted.
485 */
486 static int verifyCsrfCmd(
487 Th_Interp *interp,
488 void *p,
489 int argc,
490 const char **argv,
491 int *argl
492 ){
493 if( argc!=1 ){
494 return Th_WrongNumArgs(interp, "verifyCsrf");
495 }
496 login_verify_csrf_secret();
497 return TH_OK;
498 }
499
500 /*
501 ** TH1 command: markdown STRING
502 **
503 ** Renders the input string as markdown. The result is a two-element list.
@@ -1767,15 +1831,17 @@
1831 {"hascap", hascapCmd, (void*)&zeroInt},
1832 {"hasfeature", hasfeatureCmd, 0},
1833 {"html", putsCmd, (void*)&aFlags[0]},
1834 {"htmlize", htmlizeCmd, 0},
1835 {"http", httpCmd, 0},
1836 {"insertCsrf", insertCsrfCmd, 0},
1837 {"linecount", linecntCmd, 0},
1838 {"markdown", markdownCmd, 0},
1839 {"puts", putsCmd, (void*)&aFlags[1]},
1840 {"query", queryCmd, 0},
1841 {"randhex", randhexCmd, 0},
1842 {"redirect", redirectCmd, 0},
1843 {"regexp", regexpCmd, 0},
1844 {"reinitialize", reinitializeCmd, 0},
1845 {"render", renderCmd, 0},
1846 {"repository", repositoryCmd, 0},
1847 {"searchable", searchableCmd, 0},
@@ -1785,10 +1851,11 @@
1851 {"styleFooter", styleFooterCmd, 0},
1852 {"tclReady", tclReadyCmd, 0},
1853 {"trace", traceCmd, 0},
1854 {"stime", stimeCmd, 0},
1855 {"utime", utimeCmd, 0},
1856 {"verifyCsrf", verifyCsrfCmd, 0},
1857 {"wiki", wikiCmd, (void*)&aFlags[0]},
1858 {0, 0, 0}
1859 };
1860 if( g.thTrace ){
1861 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
@@ -2291,11 +2358,11 @@
2358 ** --http Include an HTTP response header in the output
2359 ** --open-config Open the configuration database
2360 ** --th-trace Trace TH1 execution (for debugging purposes)
2361 */
2362 void test_th_render(void){
2363 int forceCgi, fullHttpReply;
2364 Blob in;
2365 Th_InitTraceLog();
2366 forceCgi = find_option("cgi", 0, 0)!=0;
2367 fullHttpReply = find_option("http", 0, 0)!=0;
2368 if( fullHttpReply ) forceCgi = 1;
@@ -2318,11 +2385,11 @@
2385 ** COMMAND: test-th-eval
2386 **
2387 ** Usage: %fossil test-th-eval SCRIPT
2388 **
2389 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2390 ** script and show the results on standard output.
2391 **
2392 ** Options:
2393 **
2394 ** --cgi Include a CGI response header in the output
2395 ** --http Include an HTTP response header in the output
@@ -2339,15 +2406,59 @@
2406 if( fullHttpReply ) forceCgi = 1;
2407 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2408 if( find_option("open-config", 0, 0)!=0 ){
2409 Th_OpenConfig(1);
2410 }
2411 verify_all_options();
2412 if( g.argc!=3 ){
2413 usage("script");
2414 }
2415 Th_FossilInit(TH_INIT_DEFAULT);
2416 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
2417 zRc = Th_ReturnCodeName(rc, 1);
2418 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
2419 Th_PrintTraceLog();
2420 if( forceCgi ) cgi_reply();
2421 }
2422
2423 /*
2424 ** COMMAND: test-th-source
2425 **
2426 ** Usage: %fossil test-th-source FILE
2427 **
2428 ** Evaluate the contents of the file named "FILE" as if it were a header
2429 ** or footer or ticket rendering script and show the results on standard
2430 ** output.
2431 **
2432 ** Options:
2433 **
2434 ** --cgi Include a CGI response header in the output
2435 ** --http Include an HTTP response header in the output
2436 ** --open-config Open the configuration database
2437 ** --th-trace Trace TH1 execution (for debugging purposes)
2438 */
2439 void test_th_source(void){
2440 int rc;
2441 const char *zRc;
2442 int forceCgi, fullHttpReply;
2443 Blob in;
2444 Th_InitTraceLog();
2445 forceCgi = find_option("cgi", 0, 0)!=0;
2446 fullHttpReply = find_option("http", 0, 0)!=0;
2447 if( fullHttpReply ) forceCgi = 1;
2448 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2449 if( find_option("open-config", 0, 0)!=0 ){
2450 Th_OpenConfig(1);
2451 }
2452 verify_all_options();
2453 if( g.argc!=3 ){
2454 usage("file");
2455 }
2456 blob_zero(&in);
2457 blob_read_from_file(&in, g.argv[2]);
2458 Th_FossilInit(TH_INIT_DEFAULT);
2459 rc = Th_Eval(g.interp, 0, blob_str(&in), -1);
2460 zRc = Th_ReturnCodeName(rc, 1);
2461 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
2462 Th_PrintTraceLog();
2463 if( forceCgi ) cgi_reply();
2464 }
@@ -2356,11 +2467,11 @@
2467 /*
2468 ** COMMAND: test-th-hook
2469 **
2470 ** Usage: %fossil test-th-hook TYPE NAME FLAGS
2471 **
2472 ** Evaluates the TH1 script configured for the pre-operation (i.e. a command
2473 ** or web page) "hook" or post-operation "notification". The results of the
2474 ** script evaluation, if any, will be printed to the standard output channel.
2475 ** The NAME argument must be the name of a command or web page; however, it
2476 ** does not necessarily have to be a command or web page that is normally
2477 ** recognized by Fossil. The FLAGS argument will be used to set the value
@@ -2397,10 +2508,11 @@
2508 Th_InitTraceLog();
2509 forceCgi = find_option("cgi", 0, 0)!=0;
2510 fullHttpReply = find_option("http", 0, 0)!=0;
2511 if( fullHttpReply ) forceCgi = 1;
2512 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2513 verify_all_options();
2514 if( g.argc<5 ){
2515 usage("TYPE NAME FLAGS");
2516 }
2517 if( fossil_stricmp(g.argv[2], "cmdhook")==0 ){
2518 rc = Th_CommandHook(g.argv[3], (char)atoi(g.argv[4]));
2519
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
2525
2626
set testfiledir [file normalize [file dirname [info script]]]
2727
set testrundir [pwd]
2828
set testdir [file normalize [file dirname $argv0]]
2929
set fossilexe [file normalize [lindex $argv 0]]
30
+
31
+if {$tcl_platform(platform) eq "windows" && \
32
+ [string length [file extension $fossilexe]] == 0} {
33
+ append fossilexe .exe
34
+}
35
+
3036
set argv [lrange $argv 1 end]
3137
3238
set i [lsearch $argv -halt]
3339
if {$i>=0} {
3440
set HALT 1
3541
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
 
 
 
 
 
 
30 set argv [lrange $argv 1 end]
31
32 set i [lsearch $argv -halt]
33 if {$i>=0} {
34 set HALT 1
35
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
30
31 if {$tcl_platform(platform) eq "windows" && \
32 [string length [file extension $fossilexe]] == 0} {
33 append fossilexe .exe
34 }
35
36 set argv [lrange $argv 1 end]
37
38 set i [lsearch $argv -halt]
39 if {$i>=0} {
40 set HALT 1
41
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
2525
2626
set testfiledir [file normalize [file dirname [info script]]]
2727
set testrundir [pwd]
2828
set testdir [file normalize [file dirname $argv0]]
2929
set fossilexe [file normalize [lindex $argv 0]]
30
+
31
+if {$tcl_platform(platform) eq "windows" && \
32
+ [string length [file extension $fossilexe]] == 0} {
33
+ append fossilexe .exe
34
+}
35
+
3036
set argv [lrange $argv 1 end]
3137
3238
set i [lsearch $argv -halt]
3339
if {$i>=0} {
3440
set HALT 1
3541
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
 
 
 
 
 
 
30 set argv [lrange $argv 1 end]
31
32 set i [lsearch $argv -halt]
33 if {$i>=0} {
34 set HALT 1
35
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
30
31 if {$tcl_platform(platform) eq "windows" && \
32 [string length [file extension $fossilexe]] == 0} {
33 append fossilexe .exe
34 }
35
36 set argv [lrange $argv 1 end]
37
38 set i [lsearch $argv -halt]
39 if {$i>=0} {
40 set HALT 1
41
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
2525
2626
set testfiledir [file normalize [file dirname [info script]]]
2727
set testrundir [pwd]
2828
set testdir [file normalize [file dirname $argv0]]
2929
set fossilexe [file normalize [lindex $argv 0]]
30
+
31
+if {$tcl_platform(platform) eq "windows" && \
32
+ [string length [file extension $fossilexe]] == 0} {
33
+ append fossilexe .exe
34
+}
35
+
3036
set argv [lrange $argv 1 end]
3137
3238
set i [lsearch $argv -halt]
3339
if {$i>=0} {
3440
set HALT 1
3541
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
 
 
 
 
 
 
30 set argv [lrange $argv 1 end]
31
32 set i [lsearch $argv -halt]
33 if {$i>=0} {
34 set HALT 1
35
--- test/tester.tcl
+++ test/tester.tcl
@@ -25,10 +25,16 @@
25
26 set testfiledir [file normalize [file dirname [info script]]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dirname $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
30
31 if {$tcl_platform(platform) eq "windows" && \
32 [string length [file extension $fossilexe]] == 0} {
33 append fossilexe .exe
34 }
35
36 set argv [lrange $argv 1 end]
37
38 set i [lsearch $argv -halt]
39 if {$i>=0} {
40 set HALT 1
41
+45 -30
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913913
test th1-reinitialize-2 {$RESULT ne ""}
914914
915915
###############################################################################
916916
917917
#
918
-# NOTE: This test may fail if the command names do not always come out in a
919
-# deterministic order from TH1.
918
+# NOTE: This test will fail if the command names are added to TH1, or
919
+# moved from Tcl builds to plain or the reverse. Sorting the
920
+# command lists eliminates a dependence on order.
920921
#
921922
fossil test-th-eval "info commands"
922
-
923
+set sorted_result [lsort $RESULT]
924
+protOut "Sorted: $sorted_result"
925
+set base_commands {anoncap anycap array artifact break breakpoint catch\
926
+ checkout combobox continue date decorate dir enable_output encode64\
927
+ error expr for getParameter glob_match globalState hascap hasfeature\
928
+ html htmlize http httpize if info insertCsrf lindex linecount list\
929
+ llength lsearch markdown proc puts query randhex redirect regexp\
930
+ reinitialize rename render repository return searchable set\
931
+ setParameter setting stime string styleFooter styleHeader tclReady\
932
+ trace unset uplevel upvar utime verifyCsrf wiki}
933
+set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
923934
if {$th1Tcl} {
924
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926
- catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927
- html anoncap randhex llength for set break regexp markdown styleHeader\
928
- puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929
- globalState continue getParameter hasfeature setting lsearch breakpoint\
930
- upvar render repository string unset setParameter list error info rename\
931
- tclExpr array anycap tclEval httpize tclMakeSafe}}
935
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
932936
} else {
933
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935
- catch if tclReady searchable reinitialize combobox lindex query html\
936
- anoncap randhex llength for set break regexp markdown styleHeader puts\
937
- return checkout decorate artifact trace wiki proc hascap globalState\
938
- continue getParameter hasfeature setting lsearch breakpoint upvar render\
939
- repository string unset setParameter list error info rename array anycap\
940
- httpize}}
941
-}
937
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938
+}
939
+
942940
943941
###############################################################################
944942
945943
fossil test-th-eval "info vars"
946944
947945
if {$th1Hooks} {
948
- test th1-info-vars-1 {$RESULT eq \
949
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
946
+ test th1-info-vars-1 {[lsort $RESULT] eq \
947
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
950948
} else {
951949
test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952950
}
953951
954952
###############################################################################
955953
956954
fossil test-th-eval "set x 1; info vars"
957955
958956
if {$th1Hooks} {
959
- test th1-info-vars-2 {$RESULT eq \
960
- "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
957
+ test th1-info-vars-2 {[lsort $RESULT] eq \
958
+ [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
961959
} else {
962
- test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
960
+ test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
963961
}
964962
965963
###############################################################################
966964
967965
fossil test-th-eval "set x 1; unset x; info vars"
968966
969967
if {$th1Hooks} {
970
- test th1-info-vars-3 {$RESULT eq \
971
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
968
+ test th1-info-vars-3 {[lsort $RESULT] eq \
969
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
972970
} else {
973971
test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974972
}
975973
976974
###############################################################################
@@ -981,14 +979,14 @@
981979
###############################################################################
982980
983981
fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984982
985983
if {$th1Hooks} {
986
- test th1-info-vars-5 {$RESULT eq \
987
- "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
984
+ test th1-info-vars-5 {[lsort $RESULT] eq \
985
+ [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
988986
} else {
989
- test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
987
+ test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
990988
}
991989
992990
###############################################################################
993991
994992
fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
14361434
14371435
###############################################################################
14381436
14391437
fossil test-th-eval {set tcl_platform(platform)}
14401438
test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
+
1440
+###############################################################################
1441
+
1442
+set th1FileName [file join $::tempPath th1-[pid].th1]
1443
+
1444
+write_file $th1FileName {
1445
+ set x ""
1446
+ for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447
+ set x "$x $i"
1448
+ }
1449
+ return [string trim $x]
1450
+ set y; # NOTE: Never hit.
1451
+}
1452
+
1453
+fossil test-th-source $th1FileName
1454
+test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455
+file delete $th1FileName
14411456
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test may fail if the command names do not always come out in a
919 # deterministic order from TH1.
 
920 #
921 fossil test-th-eval "info commands"
922
 
 
 
 
 
 
 
 
 
 
923 if {$th1Tcl} {
924 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926 catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927 html anoncap randhex llength for set break regexp markdown styleHeader\
928 puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929 globalState continue getParameter hasfeature setting lsearch breakpoint\
930 upvar render repository string unset setParameter list error info rename\
931 tclExpr array anycap tclEval httpize tclMakeSafe}}
932 } else {
933 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935 catch if tclReady searchable reinitialize combobox lindex query html\
936 anoncap randhex llength for set break regexp markdown styleHeader puts\
937 return checkout decorate artifact trace wiki proc hascap globalState\
938 continue getParameter hasfeature setting lsearch breakpoint upvar render\
939 repository string unset setParameter list error info rename array anycap\
940 httpize}}
941 }
942
943 ###############################################################################
944
945 fossil test-th-eval "info vars"
946
947 if {$th1Hooks} {
948 test th1-info-vars-1 {$RESULT eq \
949 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
950 } else {
951 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952 }
953
954 ###############################################################################
955
956 fossil test-th-eval "set x 1; info vars"
957
958 if {$th1Hooks} {
959 test th1-info-vars-2 {$RESULT eq \
960 "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
961 } else {
962 test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
963 }
964
965 ###############################################################################
966
967 fossil test-th-eval "set x 1; unset x; info vars"
968
969 if {$th1Hooks} {
970 test th1-info-vars-3 {$RESULT eq \
971 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
972 } else {
973 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974 }
975
976 ###############################################################################
@@ -981,14 +979,14 @@
981 ###############################################################################
982
983 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984
985 if {$th1Hooks} {
986 test th1-info-vars-5 {$RESULT eq \
987 "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
988 } else {
989 test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
990 }
991
992 ###############################################################################
993
994 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1436
1437 ###############################################################################
1438
1439 fossil test-th-eval {set tcl_platform(platform)}
1440 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1441
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test will fail if the command names are added to TH1, or
919 # moved from Tcl builds to plain or the reverse. Sorting the
920 # command lists eliminates a dependence on order.
921 #
922 fossil test-th-eval "info commands"
923 set sorted_result [lsort $RESULT]
924 protOut "Sorted: $sorted_result"
925 set base_commands {anoncap anycap array artifact break breakpoint catch\
926 checkout combobox continue date decorate dir enable_output encode64\
927 error expr for getParameter glob_match globalState hascap hasfeature\
928 html htmlize http httpize if info insertCsrf lindex linecount list\
929 llength lsearch markdown proc puts query randhex redirect regexp\
930 reinitialize rename render repository return searchable set\
931 setParameter setting stime string styleFooter styleHeader tclReady\
932 trace unset uplevel upvar utime verifyCsrf wiki}
933 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
934 if {$th1Tcl} {
935 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
 
 
 
 
 
 
 
936 } else {
937 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938 }
939
 
 
 
 
 
 
940
941 ###############################################################################
942
943 fossil test-th-eval "info vars"
944
945 if {$th1Hooks} {
946 test th1-info-vars-1 {[lsort $RESULT] eq \
947 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
948 } else {
949 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
950 }
951
952 ###############################################################################
953
954 fossil test-th-eval "set x 1; info vars"
955
956 if {$th1Hooks} {
957 test th1-info-vars-2 {[lsort $RESULT] eq \
958 [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
959 } else {
960 test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
961 }
962
963 ###############################################################################
964
965 fossil test-th-eval "set x 1; unset x; info vars"
966
967 if {$th1Hooks} {
968 test th1-info-vars-3 {[lsort $RESULT] eq \
969 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
970 } else {
971 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
972 }
973
974 ###############################################################################
@@ -981,14 +979,14 @@
979 ###############################################################################
980
981 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
982
983 if {$th1Hooks} {
984 test th1-info-vars-5 {[lsort $RESULT] eq \
985 [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
986 } else {
987 test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
988 }
989
990 ###############################################################################
991
992 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1434
1435 ###############################################################################
1436
1437 fossil test-th-eval {set tcl_platform(platform)}
1438 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
1440 ###############################################################################
1441
1442 set th1FileName [file join $::tempPath th1-[pid].th1]
1443
1444 write_file $th1FileName {
1445 set x ""
1446 for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447 set x "$x $i"
1448 }
1449 return [string trim $x]
1450 set y; # NOTE: Never hit.
1451 }
1452
1453 fossil test-th-source $th1FileName
1454 test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455 file delete $th1FileName
1456
+45 -30
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913913
test th1-reinitialize-2 {$RESULT ne ""}
914914
915915
###############################################################################
916916
917917
#
918
-# NOTE: This test may fail if the command names do not always come out in a
919
-# deterministic order from TH1.
918
+# NOTE: This test will fail if the command names are added to TH1, or
919
+# moved from Tcl builds to plain or the reverse. Sorting the
920
+# command lists eliminates a dependence on order.
920921
#
921922
fossil test-th-eval "info commands"
922
-
923
+set sorted_result [lsort $RESULT]
924
+protOut "Sorted: $sorted_result"
925
+set base_commands {anoncap anycap array artifact break breakpoint catch\
926
+ checkout combobox continue date decorate dir enable_output encode64\
927
+ error expr for getParameter glob_match globalState hascap hasfeature\
928
+ html htmlize http httpize if info insertCsrf lindex linecount list\
929
+ llength lsearch markdown proc puts query randhex redirect regexp\
930
+ reinitialize rename render repository return searchable set\
931
+ setParameter setting stime string styleFooter styleHeader tclReady\
932
+ trace unset uplevel upvar utime verifyCsrf wiki}
933
+set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
923934
if {$th1Tcl} {
924
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926
- catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927
- html anoncap randhex llength for set break regexp markdown styleHeader\
928
- puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929
- globalState continue getParameter hasfeature setting lsearch breakpoint\
930
- upvar render repository string unset setParameter list error info rename\
931
- tclExpr array anycap tclEval httpize tclMakeSafe}}
935
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
932936
} else {
933
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935
- catch if tclReady searchable reinitialize combobox lindex query html\
936
- anoncap randhex llength for set break regexp markdown styleHeader puts\
937
- return checkout decorate artifact trace wiki proc hascap globalState\
938
- continue getParameter hasfeature setting lsearch breakpoint upvar render\
939
- repository string unset setParameter list error info rename array anycap\
940
- httpize}}
941
-}
937
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938
+}
939
+
942940
943941
###############################################################################
944942
945943
fossil test-th-eval "info vars"
946944
947945
if {$th1Hooks} {
948
- test th1-info-vars-1 {$RESULT eq \
949
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
946
+ test th1-info-vars-1 {[lsort $RESULT] eq \
947
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
950948
} else {
951949
test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952950
}
953951
954952
###############################################################################
955953
956954
fossil test-th-eval "set x 1; info vars"
957955
958956
if {$th1Hooks} {
959
- test th1-info-vars-2 {$RESULT eq \
960
- "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
957
+ test th1-info-vars-2 {[lsort $RESULT] eq \
958
+ [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
961959
} else {
962
- test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
960
+ test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
963961
}
964962
965963
###############################################################################
966964
967965
fossil test-th-eval "set x 1; unset x; info vars"
968966
969967
if {$th1Hooks} {
970
- test th1-info-vars-3 {$RESULT eq \
971
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
968
+ test th1-info-vars-3 {[lsort $RESULT] eq \
969
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
972970
} else {
973971
test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974972
}
975973
976974
###############################################################################
@@ -981,14 +979,14 @@
981979
###############################################################################
982980
983981
fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984982
985983
if {$th1Hooks} {
986
- test th1-info-vars-5 {$RESULT eq \
987
- "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
984
+ test th1-info-vars-5 {[lsort $RESULT] eq \
985
+ [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
988986
} else {
989
- test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
987
+ test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
990988
}
991989
992990
###############################################################################
993991
994992
fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
14361434
14371435
###############################################################################
14381436
14391437
fossil test-th-eval {set tcl_platform(platform)}
14401438
test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
+
1440
+###############################################################################
1441
+
1442
+set th1FileName [file join $::tempPath th1-[pid].th1]
1443
+
1444
+write_file $th1FileName {
1445
+ set x ""
1446
+ for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447
+ set x "$x $i"
1448
+ }
1449
+ return [string trim $x]
1450
+ set y; # NOTE: Never hit.
1451
+}
1452
+
1453
+fossil test-th-source $th1FileName
1454
+test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455
+file delete $th1FileName
14411456
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test may fail if the command names do not always come out in a
919 # deterministic order from TH1.
 
920 #
921 fossil test-th-eval "info commands"
922
 
 
 
 
 
 
 
 
 
 
923 if {$th1Tcl} {
924 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926 catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927 html anoncap randhex llength for set break regexp markdown styleHeader\
928 puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929 globalState continue getParameter hasfeature setting lsearch breakpoint\
930 upvar render repository string unset setParameter list error info rename\
931 tclExpr array anycap tclEval httpize tclMakeSafe}}
932 } else {
933 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935 catch if tclReady searchable reinitialize combobox lindex query html\
936 anoncap randhex llength for set break regexp markdown styleHeader puts\
937 return checkout decorate artifact trace wiki proc hascap globalState\
938 continue getParameter hasfeature setting lsearch breakpoint upvar render\
939 repository string unset setParameter list error info rename array anycap\
940 httpize}}
941 }
942
943 ###############################################################################
944
945 fossil test-th-eval "info vars"
946
947 if {$th1Hooks} {
948 test th1-info-vars-1 {$RESULT eq \
949 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
950 } else {
951 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952 }
953
954 ###############################################################################
955
956 fossil test-th-eval "set x 1; info vars"
957
958 if {$th1Hooks} {
959 test th1-info-vars-2 {$RESULT eq \
960 "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
961 } else {
962 test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
963 }
964
965 ###############################################################################
966
967 fossil test-th-eval "set x 1; unset x; info vars"
968
969 if {$th1Hooks} {
970 test th1-info-vars-3 {$RESULT eq \
971 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
972 } else {
973 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974 }
975
976 ###############################################################################
@@ -981,14 +979,14 @@
981 ###############################################################################
982
983 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984
985 if {$th1Hooks} {
986 test th1-info-vars-5 {$RESULT eq \
987 "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
988 } else {
989 test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
990 }
991
992 ###############################################################################
993
994 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1436
1437 ###############################################################################
1438
1439 fossil test-th-eval {set tcl_platform(platform)}
1440 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1441
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test will fail if the command names are added to TH1, or
919 # moved from Tcl builds to plain or the reverse. Sorting the
920 # command lists eliminates a dependence on order.
921 #
922 fossil test-th-eval "info commands"
923 set sorted_result [lsort $RESULT]
924 protOut "Sorted: $sorted_result"
925 set base_commands {anoncap anycap array artifact break breakpoint catch\
926 checkout combobox continue date decorate dir enable_output encode64\
927 error expr for getParameter glob_match globalState hascap hasfeature\
928 html htmlize http httpize if info insertCsrf lindex linecount list\
929 llength lsearch markdown proc puts query randhex redirect regexp\
930 reinitialize rename render repository return searchable set\
931 setParameter setting stime string styleFooter styleHeader tclReady\
932 trace unset uplevel upvar utime verifyCsrf wiki}
933 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
934 if {$th1Tcl} {
935 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
 
 
 
 
 
 
 
936 } else {
937 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938 }
939
 
 
 
 
 
 
940
941 ###############################################################################
942
943 fossil test-th-eval "info vars"
944
945 if {$th1Hooks} {
946 test th1-info-vars-1 {[lsort $RESULT] eq \
947 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
948 } else {
949 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
950 }
951
952 ###############################################################################
953
954 fossil test-th-eval "set x 1; info vars"
955
956 if {$th1Hooks} {
957 test th1-info-vars-2 {[lsort $RESULT] eq \
958 [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
959 } else {
960 test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
961 }
962
963 ###############################################################################
964
965 fossil test-th-eval "set x 1; unset x; info vars"
966
967 if {$th1Hooks} {
968 test th1-info-vars-3 {[lsort $RESULT] eq \
969 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
970 } else {
971 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
972 }
973
974 ###############################################################################
@@ -981,14 +979,14 @@
979 ###############################################################################
980
981 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
982
983 if {$th1Hooks} {
984 test th1-info-vars-5 {[lsort $RESULT] eq \
985 [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
986 } else {
987 test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
988 }
989
990 ###############################################################################
991
992 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1434
1435 ###############################################################################
1436
1437 fossil test-th-eval {set tcl_platform(platform)}
1438 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
1440 ###############################################################################
1441
1442 set th1FileName [file join $::tempPath th1-[pid].th1]
1443
1444 write_file $th1FileName {
1445 set x ""
1446 for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447 set x "$x $i"
1448 }
1449 return [string trim $x]
1450 set y; # NOTE: Never hit.
1451 }
1452
1453 fossil test-th-source $th1FileName
1454 test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455 file delete $th1FileName
1456
+45 -30
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913913
test th1-reinitialize-2 {$RESULT ne ""}
914914
915915
###############################################################################
916916
917917
#
918
-# NOTE: This test may fail if the command names do not always come out in a
919
-# deterministic order from TH1.
918
+# NOTE: This test will fail if the command names are added to TH1, or
919
+# moved from Tcl builds to plain or the reverse. Sorting the
920
+# command lists eliminates a dependence on order.
920921
#
921922
fossil test-th-eval "info commands"
922
-
923
+set sorted_result [lsort $RESULT]
924
+protOut "Sorted: $sorted_result"
925
+set base_commands {anoncap anycap array artifact break breakpoint catch\
926
+ checkout combobox continue date decorate dir enable_output encode64\
927
+ error expr for getParameter glob_match globalState hascap hasfeature\
928
+ html htmlize http httpize if info insertCsrf lindex linecount list\
929
+ llength lsearch markdown proc puts query randhex redirect regexp\
930
+ reinitialize rename render repository return searchable set\
931
+ setParameter setting stime string styleFooter styleHeader tclReady\
932
+ trace unset uplevel upvar utime verifyCsrf wiki}
933
+set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
923934
if {$th1Tcl} {
924
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926
- catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927
- html anoncap randhex llength for set break regexp markdown styleHeader\
928
- puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929
- globalState continue getParameter hasfeature setting lsearch breakpoint\
930
- upvar render repository string unset setParameter list error info rename\
931
- tclExpr array anycap tclEval httpize tclMakeSafe}}
935
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
932936
} else {
933
- test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934
- enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935
- catch if tclReady searchable reinitialize combobox lindex query html\
936
- anoncap randhex llength for set break regexp markdown styleHeader puts\
937
- return checkout decorate artifact trace wiki proc hascap globalState\
938
- continue getParameter hasfeature setting lsearch breakpoint upvar render\
939
- repository string unset setParameter list error info rename array anycap\
940
- httpize}}
941
-}
937
+ test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938
+}
939
+
942940
943941
###############################################################################
944942
945943
fossil test-th-eval "info vars"
946944
947945
if {$th1Hooks} {
948
- test th1-info-vars-1 {$RESULT eq \
949
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
946
+ test th1-info-vars-1 {[lsort $RESULT] eq \
947
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
950948
} else {
951949
test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952950
}
953951
954952
###############################################################################
955953
956954
fossil test-th-eval "set x 1; info vars"
957955
958956
if {$th1Hooks} {
959
- test th1-info-vars-2 {$RESULT eq \
960
- "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
957
+ test th1-info-vars-2 {[lsort $RESULT] eq \
958
+ [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
961959
} else {
962
- test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
960
+ test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
963961
}
964962
965963
###############################################################################
966964
967965
fossil test-th-eval "set x 1; unset x; info vars"
968966
969967
if {$th1Hooks} {
970
- test th1-info-vars-3 {$RESULT eq \
971
- "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
968
+ test th1-info-vars-3 {[lsort $RESULT] eq \
969
+ [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
972970
} else {
973971
test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974972
}
975973
976974
###############################################################################
@@ -981,14 +979,14 @@
981979
###############################################################################
982980
983981
fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984982
985983
if {$th1Hooks} {
986
- test th1-info-vars-5 {$RESULT eq \
987
- "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
984
+ test th1-info-vars-5 {[lsort $RESULT] eq \
985
+ [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
988986
} else {
989
- test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
987
+ test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
990988
}
991989
992990
###############################################################################
993991
994992
fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
14361434
14371435
###############################################################################
14381436
14391437
fossil test-th-eval {set tcl_platform(platform)}
14401438
test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
+
1440
+###############################################################################
1441
+
1442
+set th1FileName [file join $::tempPath th1-[pid].th1]
1443
+
1444
+write_file $th1FileName {
1445
+ set x ""
1446
+ for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447
+ set x "$x $i"
1448
+ }
1449
+ return [string trim $x]
1450
+ set y; # NOTE: Never hit.
1451
+}
1452
+
1453
+fossil test-th-source $th1FileName
1454
+test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455
+file delete $th1FileName
14411456
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test may fail if the command names do not always come out in a
919 # deterministic order from TH1.
 
920 #
921 fossil test-th-eval "info commands"
922
 
 
 
 
 
 
 
 
 
 
923 if {$th1Tcl} {
924 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
925 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
926 catch if tclReady searchable reinitialize combobox lindex tclIsSafe query\
927 html anoncap randhex llength for set break regexp markdown styleHeader\
928 puts return checkout decorate artifact trace wiki proc tclInvoke hascap\
929 globalState continue getParameter hasfeature setting lsearch breakpoint\
930 upvar render repository string unset setParameter list error info rename\
931 tclExpr array anycap tclEval httpize tclMakeSafe}}
932 } else {
933 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
934 enable_output uplevel dir http expr glob_match utime styleFooter encode64\
935 catch if tclReady searchable reinitialize combobox lindex query html\
936 anoncap randhex llength for set break regexp markdown styleHeader puts\
937 return checkout decorate artifact trace wiki proc hascap globalState\
938 continue getParameter hasfeature setting lsearch breakpoint upvar render\
939 repository string unset setParameter list error info rename array anycap\
940 httpize}}
941 }
942
943 ###############################################################################
944
945 fossil test-th-eval "info vars"
946
947 if {$th1Hooks} {
948 test th1-info-vars-1 {$RESULT eq \
949 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
950 } else {
951 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
952 }
953
954 ###############################################################################
955
956 fossil test-th-eval "set x 1; info vars"
957
958 if {$th1Hooks} {
959 test th1-info-vars-2 {$RESULT eq \
960 "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
961 } else {
962 test th1-info-vars-2 {$RESULT eq "x tcl_platform"}
963 }
964
965 ###############################################################################
966
967 fossil test-th-eval "set x 1; unset x; info vars"
968
969 if {$th1Hooks} {
970 test th1-info-vars-3 {$RESULT eq \
971 "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"}
972 } else {
973 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
974 }
975
976 ###############################################################################
@@ -981,14 +979,14 @@
981 ###############################################################################
982
983 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
984
985 if {$th1Hooks} {
986 test th1-info-vars-5 {$RESULT eq \
987 "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"}
988 } else {
989 test th1-info-vars-5 {$RESULT eq "y tcl_platform"}
990 }
991
992 ###############################################################################
993
994 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1436
1437 ###############################################################################
1438
1439 fossil test-th-eval {set tcl_platform(platform)}
1440 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1441
--- test/th1.test
+++ test/th1.test
@@ -913,64 +913,62 @@
913 test th1-reinitialize-2 {$RESULT ne ""}
914
915 ###############################################################################
916
917 #
918 # NOTE: This test will fail if the command names are added to TH1, or
919 # moved from Tcl builds to plain or the reverse. Sorting the
920 # command lists eliminates a dependence on order.
921 #
922 fossil test-th-eval "info commands"
923 set sorted_result [lsort $RESULT]
924 protOut "Sorted: $sorted_result"
925 set base_commands {anoncap anycap array artifact break breakpoint catch\
926 checkout combobox continue date decorate dir enable_output encode64\
927 error expr for getParameter glob_match globalState hascap hasfeature\
928 html htmlize http httpize if info insertCsrf lindex linecount list\
929 llength lsearch markdown proc puts query randhex redirect regexp\
930 reinitialize rename render repository return searchable set\
931 setParameter setting stime string styleFooter styleHeader tclReady\
932 trace unset uplevel upvar utime verifyCsrf wiki}
933 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
934 if {$th1Tcl} {
935 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
 
 
 
 
 
 
 
936 } else {
937 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
938 }
939
 
 
 
 
 
 
940
941 ###############################################################################
942
943 fossil test-th-eval "info vars"
944
945 if {$th1Hooks} {
946 test th1-info-vars-1 {[lsort $RESULT] eq \
947 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
948 } else {
949 test th1-info-vars-1 {$RESULT eq "tcl_platform"}
950 }
951
952 ###############################################################################
953
954 fossil test-th-eval "set x 1; info vars"
955
956 if {$th1Hooks} {
957 test th1-info-vars-2 {[lsort $RESULT] eq \
958 [lsort "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
959 } else {
960 test th1-info-vars-2 {[lsort $RESULT] eq [lsort "x tcl_platform"]}
961 }
962
963 ###############################################################################
964
965 fossil test-th-eval "set x 1; unset x; info vars"
966
967 if {$th1Hooks} {
968 test th1-info-vars-3 {[lsort $RESULT] eq \
969 [lsort "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"]}
970 } else {
971 test th1-info-vars-3 {$RESULT eq "tcl_platform"}
972 }
973
974 ###############################################################################
@@ -981,14 +979,14 @@
979 ###############################################################################
980
981 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
982
983 if {$th1Hooks} {
984 test th1-info-vars-5 {[lsort $RESULT] eq \
985 [lsort "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"]}
986 } else {
987 test th1-info-vars-5 {[lsort $RESULT] eq [lsort "y tcl_platform"]}
988 }
989
990 ###############################################################################
991
992 fossil test-th-eval "array exists foo"
@@ -1436,5 +1434,22 @@
1434
1435 ###############################################################################
1436
1437 fossil test-th-eval {set tcl_platform(platform)}
1438 test th1-platform-4 {$RESULT eq "windows" || $RESULT eq "unix"}
1439
1440 ###############################################################################
1441
1442 set th1FileName [file join $::tempPath th1-[pid].th1]
1443
1444 write_file $th1FileName {
1445 set x ""
1446 for {set i 0} {$i < 10} {set i [expr {$i + 1}]} {
1447 set x "$x $i"
1448 }
1449 return [string trim $x]
1450 set y; # NOTE: Never hit.
1451 }
1452
1453 fossil test-th-source $th1FileName
1454 test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455 file delete $th1FileName
1456
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -158,11 +158,11 @@
158158
#### The directories where the OpenSSL include and library files are located.
159159
# The recommended usage here is to use the Sysinternals junction tool
160160
# to create a hard link between an "openssl-1.x" sub-directory of the
161161
# Fossil source code directory and the target OpenSSL source directory.
162162
#
163
-OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
163
+OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
164164
OPENSSLINCDIR = $(OPENSSLDIR)/include
165165
OPENSSLLIBDIR = $(OPENSSLDIR)
166166
167167
#### Either the directory where the Tcl library is installed or the Tcl
168168
# source code directory resides (depending on the value of the macro
169169
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -158,11 +158,11 @@
158 #### The directories where the OpenSSL include and library files are located.
159 # The recommended usage here is to use the Sysinternals junction tool
160 # to create a hard link between an "openssl-1.x" sub-directory of the
161 # Fossil source code directory and the target OpenSSL source directory.
162 #
163 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
164 OPENSSLINCDIR = $(OPENSSLDIR)/include
165 OPENSSLLIBDIR = $(OPENSSLDIR)
166
167 #### Either the directory where the Tcl library is installed or the Tcl
168 # source code directory resides (depending on the value of the macro
169
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -158,11 +158,11 @@
158 #### The directories where the OpenSSL include and library files are located.
159 # The recommended usage here is to use the Sysinternals junction tool
160 # to create a hard link between an "openssl-1.x" sub-directory of the
161 # Fossil source code directory and the target OpenSSL source directory.
162 #
163 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
164 OPENSSLINCDIR = $(OPENSSLDIR)/include
165 OPENSSLLIBDIR = $(OPENSSLDIR)
166
167 #### Either the directory where the Tcl library is installed or the Tcl
168 # source code directory resides (depending on the value of the macro
169
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -158,11 +158,11 @@
158158
#### The directories where the OpenSSL include and library files are located.
159159
# The recommended usage here is to use the Sysinternals junction tool
160160
# to create a hard link between an "openssl-1.x" sub-directory of the
161161
# Fossil source code directory and the target OpenSSL source directory.
162162
#
163
-OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
163
+OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
164164
OPENSSLINCDIR = $(OPENSSLDIR)/include
165165
OPENSSLLIBDIR = $(OPENSSLDIR)
166166
167167
#### Either the directory where the Tcl library is installed or the Tcl
168168
# source code directory resides (depending on the value of the macro
169169
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -158,11 +158,11 @@
158 #### The directories where the OpenSSL include and library files are located.
159 # The recommended usage here is to use the Sysinternals junction tool
160 # to create a hard link between an "openssl-1.x" sub-directory of the
161 # Fossil source code directory and the target OpenSSL source directory.
162 #
163 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2e
164 OPENSSLINCDIR = $(OPENSSLDIR)/include
165 OPENSSLLIBDIR = $(OPENSSLDIR)
166
167 #### Either the directory where the Tcl library is installed or the Tcl
168 # source code directory resides (depending on the value of the macro
169
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -158,11 +158,11 @@
158 #### The directories where the OpenSSL include and library files are located.
159 # The recommended usage here is to use the Sysinternals junction tool
160 # to create a hard link between an "openssl-1.x" sub-directory of the
161 # Fossil source code directory and the target OpenSSL source directory.
162 #
163 OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2f
164 OPENSSLINCDIR = $(OPENSSLDIR)/include
165 OPENSSLLIBDIR = $(OPENSSLDIR)
166
167 #### Either the directory where the Tcl library is installed or the Tcl
168 # source code directory resides (depending on the value of the macro
169
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -93,11 +93,11 @@
9393
!ifndef FOSSIL_ENABLE_WINXP
9494
FOSSIL_ENABLE_WINXP = 0
9595
!endif
9696
9797
!if $(FOSSIL_ENABLE_SSL)!=0
98
-SSLDIR = $(B)\compat\openssl-1.0.2e
98
+SSLDIR = $(B)\compat\openssl-1.0.2f
9999
SSLINCDIR = $(SSLDIR)\inc32
100100
!if $(FOSSIL_DYNAMIC_BUILD)!=0
101101
SSLLIBDIR = $(SSLDIR)\out32dll
102102
!else
103103
SSLLIBDIR = $(SSLDIR)\out32
104104
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -93,11 +93,11 @@
93 !ifndef FOSSIL_ENABLE_WINXP
94 FOSSIL_ENABLE_WINXP = 0
95 !endif
96
97 !if $(FOSSIL_ENABLE_SSL)!=0
98 SSLDIR = $(B)\compat\openssl-1.0.2e
99 SSLINCDIR = $(SSLDIR)\inc32
100 !if $(FOSSIL_DYNAMIC_BUILD)!=0
101 SSLLIBDIR = $(SSLDIR)\out32dll
102 !else
103 SSLLIBDIR = $(SSLDIR)\out32
104
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -93,11 +93,11 @@
93 !ifndef FOSSIL_ENABLE_WINXP
94 FOSSIL_ENABLE_WINXP = 0
95 !endif
96
97 !if $(FOSSIL_ENABLE_SSL)!=0
98 SSLDIR = $(B)\compat\openssl-1.0.2f
99 SSLINCDIR = $(SSLDIR)\inc32
100 !if $(FOSSIL_DYNAMIC_BUILD)!=0
101 SSLLIBDIR = $(SSLDIR)\out32dll
102 !else
103 SSLLIBDIR = $(SSLDIR)\out32
104
--- win/buildmsvc.bat
+++ win/buildmsvc.bat
@@ -259,12 +259,14 @@
259259
CALL :fn_UnsetVariable PFILES_SDK71A
260260
SET NMAKE_ARGS=%NMAKE_ARGS% FOSSIL_ENABLE_WINXP=1
261261
GOTO :EOF
262262
263263
:fn_UnsetVariable
264
- IF NOT "%1" == "" (
265
- SET %1=
264
+ SET VALUE=%1
265
+ IF DEFINED VALUE (
266
+ SET %VALUE%=
267
+ SET VALUE=
266268
CALL :fn_ResetErrorLevel
267269
)
268270
GOTO :EOF
269271
270272
:fn_ResetErrorLevel
271273
--- win/buildmsvc.bat
+++ win/buildmsvc.bat
@@ -259,12 +259,14 @@
259 CALL :fn_UnsetVariable PFILES_SDK71A
260 SET NMAKE_ARGS=%NMAKE_ARGS% FOSSIL_ENABLE_WINXP=1
261 GOTO :EOF
262
263 :fn_UnsetVariable
264 IF NOT "%1" == "" (
265 SET %1=
 
 
266 CALL :fn_ResetErrorLevel
267 )
268 GOTO :EOF
269
270 :fn_ResetErrorLevel
271
--- win/buildmsvc.bat
+++ win/buildmsvc.bat
@@ -259,12 +259,14 @@
259 CALL :fn_UnsetVariable PFILES_SDK71A
260 SET NMAKE_ARGS=%NMAKE_ARGS% FOSSIL_ENABLE_WINXP=1
261 GOTO :EOF
262
263 :fn_UnsetVariable
264 SET VALUE=%1
265 IF DEFINED VALUE (
266 SET %VALUE%=
267 SET VALUE=
268 CALL :fn_ResetErrorLevel
269 )
270 GOTO :EOF
271
272 :fn_ResetErrorLevel
273
+14 -8
--- www/build.wiki
+++ www/build.wiki
@@ -111,23 +111,29 @@
111111
<li><p><i>Unix without running "configure"</i> → if you prefer to avoid
112112
running configure, you can also use: <b>make -f Makefile.classic</b>. You may
113113
want to make minor edits to Makefile.classic to configure the build for your
114114
system.
115115
116
-<li><p><i>MinGW3.x (not 4.0)/MinGW-w64</i> → Use the mingw makefile:
117
-"<b>make -f win/Makefile.mingw</b>". On a Windows box you will
118
-need either Cygwin or Msys as build environment. On Cygwin, Linux
119
-or Darwin you may want to make minor edits to win/Makefile.mingw
120
-to configure the cross-compile environment.
116
+<li><p><i>MinGW 3.x (<u>not</u> 4.x) / MinGW-w64</i> → Use the MinGW makefile:
117
+"<b>make -f win/Makefile.mingw</b>". On a Windows box you will need either
118
+Cygwin or Msys as build environment. On Cygwin, Linux or Darwin you may want
119
+to make minor edits to win/Makefile.mingw to configure the cross-compile
120
+environment.
121121
122122
To enable the native [./th1.md#tclEval | Tcl integration feature], use a
123123
command line like the following (all on one line):
124124
125125
<b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
126126
127
-Hint: don't use MinGW-4.0, it will compile but fossil won't work correctly, see
128
-<a href="https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c">https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c</a>.
127
+Alternatively, <b>./configure</b> may now be used to create a Makefile
128
+suitable for use with MinGW; however, options passed to configure that are
129
+not applicable on Windows may cause the configuration or compilation to fail
130
+(e.g. fusefs, internal-sqlite, etc).
131
+
132
+<i>HINT</i>: Do <u>not</u> use MinGW-4.x, it may compile but the Fossil binary
133
+will not work correctly, see
134
+[https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c | ticket].
129135
130136
<li><p><i>MSVC</i> → Use the MSVC makefile. First
131137
change to the "win/" subdirectory ("<b>cd win</b>") then run
132138
"<b>nmake /f Makefile.msc</b>".<br><br>Alternatively, the batch
133139
file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
@@ -135,11 +141,11 @@
135141
the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
136142
first <a href="https://www.openssl.org/source/">download the official
137143
source code for OpenSSL</a> and extract it to an appropriately named
138144
"<b>openssl-X.Y.ZA</b>" subdirectory within the local
139145
[/tree?ci=trunk&name=compat | compat] directory (e.g.
140
-"<b>compat/openssl-1.0.2e</b>"), then make sure that some recent
146
+"<b>compat/openssl-1.0.2f</b>"), then make sure that some recent
141147
<a href="http://www.perl.org/">Perl</a> binaries are installed locally,
142148
and finally run one of the following commands:
143149
<blockquote><pre>
144150
nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
145151
</pre></blockquote>
146152
--- www/build.wiki
+++ www/build.wiki
@@ -111,23 +111,29 @@
111 <li><p><i>Unix without running "configure"</i> → if you prefer to avoid
112 running configure, you can also use: <b>make -f Makefile.classic</b>. You may
113 want to make minor edits to Makefile.classic to configure the build for your
114 system.
115
116 <li><p><i>MinGW3.x (not 4.0)/MinGW-w64</i> → Use the mingw makefile:
117 "<b>make -f win/Makefile.mingw</b>". On a Windows box you will
118 need either Cygwin or Msys as build environment. On Cygwin, Linux
119 or Darwin you may want to make minor edits to win/Makefile.mingw
120 to configure the cross-compile environment.
121
122 To enable the native [./th1.md#tclEval | Tcl integration feature], use a
123 command line like the following (all on one line):
124
125 <b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
126
127 Hint: don't use MinGW-4.0, it will compile but fossil won't work correctly, see
128 <a href="https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c">https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c</a>.
 
 
 
 
 
 
129
130 <li><p><i>MSVC</i> → Use the MSVC makefile. First
131 change to the "win/" subdirectory ("<b>cd win</b>") then run
132 "<b>nmake /f Makefile.msc</b>".<br><br>Alternatively, the batch
133 file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
@@ -135,11 +141,11 @@
135 the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
136 first <a href="https://www.openssl.org/source/">download the official
137 source code for OpenSSL</a> and extract it to an appropriately named
138 "<b>openssl-X.Y.ZA</b>" subdirectory within the local
139 [/tree?ci=trunk&name=compat | compat] directory (e.g.
140 "<b>compat/openssl-1.0.2e</b>"), then make sure that some recent
141 <a href="http://www.perl.org/">Perl</a> binaries are installed locally,
142 and finally run one of the following commands:
143 <blockquote><pre>
144 nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
145 </pre></blockquote>
146
--- www/build.wiki
+++ www/build.wiki
@@ -111,23 +111,29 @@
111 <li><p><i>Unix without running "configure"</i> → if you prefer to avoid
112 running configure, you can also use: <b>make -f Makefile.classic</b>. You may
113 want to make minor edits to Makefile.classic to configure the build for your
114 system.
115
116 <li><p><i>MinGW 3.x (<u>not</u> 4.x) / MinGW-w64</i> → Use the MinGW makefile:
117 "<b>make -f win/Makefile.mingw</b>". On a Windows box you will need either
118 Cygwin or Msys as build environment. On Cygwin, Linux or Darwin you may want
119 to make minor edits to win/Makefile.mingw to configure the cross-compile
120 environment.
121
122 To enable the native [./th1.md#tclEval | Tcl integration feature], use a
123 command line like the following (all on one line):
124
125 <b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
126
127 Alternatively, <b>./configure</b> may now be used to create a Makefile
128 suitable for use with MinGW; however, options passed to configure that are
129 not applicable on Windows may cause the configuration or compilation to fail
130 (e.g. fusefs, internal-sqlite, etc).
131
132 <i>HINT</i>: Do <u>not</u> use MinGW-4.x, it may compile but the Fossil binary
133 will not work correctly, see
134 [https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c | ticket].
135
136 <li><p><i>MSVC</i> → Use the MSVC makefile. First
137 change to the "win/" subdirectory ("<b>cd win</b>") then run
138 "<b>nmake /f Makefile.msc</b>".<br><br>Alternatively, the batch
139 file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
@@ -135,11 +141,11 @@
141 the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
142 first <a href="https://www.openssl.org/source/">download the official
143 source code for OpenSSL</a> and extract it to an appropriately named
144 "<b>openssl-X.Y.ZA</b>" subdirectory within the local
145 [/tree?ci=trunk&name=compat | compat] directory (e.g.
146 "<b>compat/openssl-1.0.2f</b>"), then make sure that some recent
147 <a href="http://www.perl.org/">Perl</a> binaries are installed locally,
148 and finally run one of the following commands:
149 <blockquote><pre>
150 nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
151 </pre></blockquote>
152
+30
--- www/th1.md
+++ www/th1.md
@@ -150,15 +150,17 @@
150150
* hasfeature
151151
* html
152152
* htmlize
153153
* http
154154
* httpize
155
+ * insertCsrf
155156
* linecount
156157
* markdown
157158
* puts
158159
* query
159160
* randhex
161
+ * redirect
160162
* regexp
161163
* reinitialize
162164
* render
163165
* repository
164166
* searchable
@@ -173,10 +175,11 @@
173175
* tclMakeSafe
174176
* tclReady
175177
* trace
176178
* stime
177179
* utime
180
+ * verifyCsrf
178181
* wiki
179182
180183
Each of the commands above is documented by a block comment above their
181184
implementation in the th\_main.c or th\_tcl.c source files.
182185
@@ -378,10 +381,18 @@
378381
379382
* httpize STRING
380383
381384
Escape all characters of STRING which have special meaning in URI
382385
components. Returns the escaped string.
386
+
387
+<a name="insertCsrf"></a>TH1 insertCsrf Command
388
+-----------------------------------------------
389
+
390
+ * insertCsrf
391
+
392
+While rendering a form, call this command to add the Anti-CSRF token
393
+as a hidden element of the form.
383394
384395
<a name="linecount"></a>TH1 linecount Command
385396
---------------------------------------------
386397
387398
* linecount STRING MAX MIN
@@ -422,10 +433,18 @@
422433
423434
* randhex N
424435
425436
Returns a string of N*2 random hexadecimal digits with N<50. If N is
426437
omitted, use a value of 10.
438
+
439
+<a name="redirect"></a>TH1 redirect Command
440
+-------------------------------------------
441
+
442
+ * redirect URL
443
+
444
+Issues an HTTP redirect (302) to the specified URL and then exits the
445
+process.
427446
428447
<a name="regexp"></a>TH1 regexp Command
429448
---------------------------------------
430449
431450
* regexp ?-nocase? ?--? exp string
@@ -598,10 +617,21 @@
598617
599618
* utime
600619
601620
Returns the number of microseconds of CPU time consumed by the current
602621
process in user space.
622
+
623
+<a name="verifyCsrf"></a>TH1 verifyCsrf Command
624
+-----------------------------------------------
625
+
626
+ * verifyCsrf
627
+
628
+Before using the results of a form, first call this command to verify
629
+that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
630
+is missing or is incorrect, that indicates a cross-site scripting attack.
631
+If the event of an attack is detected, an error message is generated and
632
+all further processing is aborted.
603633
604634
<a name="wiki"></a>TH1 wiki Command
605635
-----------------------------------
606636
607637
* wiki STRING
608638
--- www/th1.md
+++ www/th1.md
@@ -150,15 +150,17 @@
150 * hasfeature
151 * html
152 * htmlize
153 * http
154 * httpize
 
155 * linecount
156 * markdown
157 * puts
158 * query
159 * randhex
 
160 * regexp
161 * reinitialize
162 * render
163 * repository
164 * searchable
@@ -173,10 +175,11 @@
173 * tclMakeSafe
174 * tclReady
175 * trace
176 * stime
177 * utime
 
178 * wiki
179
180 Each of the commands above is documented by a block comment above their
181 implementation in the th\_main.c or th\_tcl.c source files.
182
@@ -378,10 +381,18 @@
378
379 * httpize STRING
380
381 Escape all characters of STRING which have special meaning in URI
382 components. Returns the escaped string.
 
 
 
 
 
 
 
 
383
384 <a name="linecount"></a>TH1 linecount Command
385 ---------------------------------------------
386
387 * linecount STRING MAX MIN
@@ -422,10 +433,18 @@
422
423 * randhex N
424
425 Returns a string of N*2 random hexadecimal digits with N<50. If N is
426 omitted, use a value of 10.
 
 
 
 
 
 
 
 
427
428 <a name="regexp"></a>TH1 regexp Command
429 ---------------------------------------
430
431 * regexp ?-nocase? ?--? exp string
@@ -598,10 +617,21 @@
598
599 * utime
600
601 Returns the number of microseconds of CPU time consumed by the current
602 process in user space.
 
 
 
 
 
 
 
 
 
 
 
603
604 <a name="wiki"></a>TH1 wiki Command
605 -----------------------------------
606
607 * wiki STRING
608
--- www/th1.md
+++ www/th1.md
@@ -150,15 +150,17 @@
150 * hasfeature
151 * html
152 * htmlize
153 * http
154 * httpize
155 * insertCsrf
156 * linecount
157 * markdown
158 * puts
159 * query
160 * randhex
161 * redirect
162 * regexp
163 * reinitialize
164 * render
165 * repository
166 * searchable
@@ -173,10 +175,11 @@
175 * tclMakeSafe
176 * tclReady
177 * trace
178 * stime
179 * utime
180 * verifyCsrf
181 * wiki
182
183 Each of the commands above is documented by a block comment above their
184 implementation in the th\_main.c or th\_tcl.c source files.
185
@@ -378,10 +381,18 @@
381
382 * httpize STRING
383
384 Escape all characters of STRING which have special meaning in URI
385 components. Returns the escaped string.
386
387 <a name="insertCsrf"></a>TH1 insertCsrf Command
388 -----------------------------------------------
389
390 * insertCsrf
391
392 While rendering a form, call this command to add the Anti-CSRF token
393 as a hidden element of the form.
394
395 <a name="linecount"></a>TH1 linecount Command
396 ---------------------------------------------
397
398 * linecount STRING MAX MIN
@@ -422,10 +433,18 @@
433
434 * randhex N
435
436 Returns a string of N*2 random hexadecimal digits with N<50. If N is
437 omitted, use a value of 10.
438
439 <a name="redirect"></a>TH1 redirect Command
440 -------------------------------------------
441
442 * redirect URL
443
444 Issues an HTTP redirect (302) to the specified URL and then exits the
445 process.
446
447 <a name="regexp"></a>TH1 regexp Command
448 ---------------------------------------
449
450 * regexp ?-nocase? ?--? exp string
@@ -598,10 +617,21 @@
617
618 * utime
619
620 Returns the number of microseconds of CPU time consumed by the current
621 process in user space.
622
623 <a name="verifyCsrf"></a>TH1 verifyCsrf Command
624 -----------------------------------------------
625
626 * verifyCsrf
627
628 Before using the results of a form, first call this command to verify
629 that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
630 is missing or is incorrect, that indicates a cross-site scripting attack.
631 If the event of an attack is detected, an error message is generated and
632 all further processing is aborted.
633
634 <a name="wiki"></a>TH1 wiki Command
635 -----------------------------------
636
637 * wiki STRING
638

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button