Fossil SCM

Make the TH1 redirect command an error outside a web request, so that it no longer crashes when run from the command line, for example by test-th-eval.

dmestas 2026-11-21 11:54 UTC small-fixes
Commit 419f6955b5c58180be5a65b2a8d72799d520f92d1ac5b5ec0f41194d658df409
1 file changed +5
--- src/th_main.c
+++ src/th_main.c
@@ -520,10 +520,15 @@
520520
){
521521
int withMethod = 0;
522522
if( argc!=2 && argc!=3 ){
523523
return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524524
}
525
+ if( !g.isHTTP ){
526
+ Th_ErrorMessage(interp, "redirect is only allowed in a web request",
527
+ 0, 0);
528
+ return TH_ERROR;
529
+ }
525530
if( argc==3 ){
526531
if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
527532
return TH_ERROR;
528533
}
529534
}
530535
--- src/th_main.c
+++ src/th_main.c
@@ -520,10 +520,15 @@
520 ){
521 int withMethod = 0;
522 if( argc!=2 && argc!=3 ){
523 return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524 }
 
 
 
 
 
525 if( argc==3 ){
526 if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
527 return TH_ERROR;
528 }
529 }
530
--- src/th_main.c
+++ src/th_main.c
@@ -520,10 +520,15 @@
520 ){
521 int withMethod = 0;
522 if( argc!=2 && argc!=3 ){
523 return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524 }
525 if( !g.isHTTP ){
526 Th_ErrorMessage(interp, "redirect is only allowed in a web request",
527 0, 0);
528 return TH_ERROR;
529 }
530 if( argc==3 ){
531 if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
532 return TH_ERROR;
533 }
534 }
535

Keyboard Shortcuts

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