Fossil SCM

Refuse the TH1 redirect command only when there is no reply to write or a relative URL has no base URL, so that test-th-eval --cgi and --http still send a redirect to a full URL.

dmestas 2026-11-21 12:05 UTC small-fixes
Commit a0871ef274a3799d7135af5fe8840e493f12c1761f9447266a0b65b57d432181
1 file changed +4 -1
+4 -1
--- src/th_main.c
+++ src/th_main.c
@@ -520,11 +520,14 @@
520520
){
521521
int withMethod = 0;
522522
if( argc!=2 && argc!=3 ){
523523
return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524524
}
525
- if( !g.isHTTP ){
525
+ if( g.httpOut==0
526
+ || (g.zBaseURL==0 && fossil_strncmp(argv[1],"http:",5)!=0
527
+ && fossil_strncmp(argv[1],"https:",6)!=0)
528
+ ){
526529
Th_ErrorMessage(interp, "redirect is only allowed in a web request",
527530
0, 0);
528531
return TH_ERROR;
529532
}
530533
if( argc==3 ){
531534
--- src/th_main.c
+++ src/th_main.c
@@ -520,11 +520,14 @@
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
--- src/th_main.c
+++ src/th_main.c
@@ -520,11 +520,14 @@
520 ){
521 int withMethod = 0;
522 if( argc!=2 && argc!=3 ){
523 return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524 }
525 if( g.httpOut==0
526 || (g.zBaseURL==0 && fossil_strncmp(argv[1],"http:",5)!=0
527 && fossil_strncmp(argv[1],"https:",6)!=0)
528 ){
529 Th_ErrorMessage(interp, "redirect is only allowed in a web request",
530 0, 0);
531 return TH_ERROR;
532 }
533 if( argc==3 ){
534

Keyboard Shortcuts

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