Fossil SCM

In http_exchange(), check a redirect target in a local URL before it replaces g.url. A refused redirect now leaves g.url unchanged, so a later pass of sync --all and the remote named by sync -v use the original URL, and the connection is closed by its own kind.

dmestas 2026-11-24 19:41 UTC small-fixes
Commit 71f60497bb35b29ca66b248ce22aa0c57bdef0e18eaac5cf24824284327428ea
1 file changed +7 -3
+7 -3
--- src/http.c
+++ src/http.c
@@ -727,10 +727,11 @@
727727
fossil_strnicmp(zLine, "location:", 9)==0 ){
728728
int i, j;
729729
int wasHttps;
730730
int wasProxy;
731731
int priorUrlFlags;
732
+ UrlData target;
732733
733734
if ( --maxRedirect == 0){
734735
if( (mHttpFlags & HTTP_QUIET)==0 ){
735736
fossil_warning("redirect limit exceeded");
736737
}
@@ -757,24 +758,27 @@
757758
goto write_err;
758759
}
759760
wasHttps = g.url.isHttps;
760761
wasProxy = g.url.useProxy;
761762
priorUrlFlags = g.url.flags;
762
- url_parse(&zLine[i], 0);
763
- if( wasHttps && !g.url.isHttps ){
763
+ url_parse_local(&zLine[i], 0, &target);
764
+ if( wasHttps && !target.isHttps ){
764765
if( (mHttpFlags & HTTP_QUIET)==0 ){
765766
fossil_warning("cannot redirect from HTTPS to HTTP");
766767
}
768
+ url_unparse(&target);
767769
goto write_err;
768770
}
769
- if( g.url.isSsh || g.url.isFile ){
771
+ if( target.isSsh || target.isFile ){
770772
if( (mHttpFlags & HTTP_QUIET)==0 ){
771773
fossil_warning("cannot redirect to %s", &zLine[i]);
772774
}
775
+ url_unparse(&target);
773776
goto write_err;
774777
}
775778
transport_close(&g.url);
779
+ g.url = target;
776780
transport_global_shutdown(&g.url);
777781
fSeenHttpAuth = 0;
778782
if( g.zHttpAuth ) free(g.zHttpAuth);
779783
g.zHttpAuth = get_httpauth();
780784
if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
781785
--- src/http.c
+++ src/http.c
@@ -727,10 +727,11 @@
727 fossil_strnicmp(zLine, "location:", 9)==0 ){
728 int i, j;
729 int wasHttps;
730 int wasProxy;
731 int priorUrlFlags;
 
732
733 if ( --maxRedirect == 0){
734 if( (mHttpFlags & HTTP_QUIET)==0 ){
735 fossil_warning("redirect limit exceeded");
736 }
@@ -757,24 +758,27 @@
757 goto write_err;
758 }
759 wasHttps = g.url.isHttps;
760 wasProxy = g.url.useProxy;
761 priorUrlFlags = g.url.flags;
762 url_parse(&zLine[i], 0);
763 if( wasHttps && !g.url.isHttps ){
764 if( (mHttpFlags & HTTP_QUIET)==0 ){
765 fossil_warning("cannot redirect from HTTPS to HTTP");
766 }
 
767 goto write_err;
768 }
769 if( g.url.isSsh || g.url.isFile ){
770 if( (mHttpFlags & HTTP_QUIET)==0 ){
771 fossil_warning("cannot redirect to %s", &zLine[i]);
772 }
 
773 goto write_err;
774 }
775 transport_close(&g.url);
 
776 transport_global_shutdown(&g.url);
777 fSeenHttpAuth = 0;
778 if( g.zHttpAuth ) free(g.zHttpAuth);
779 g.zHttpAuth = get_httpauth();
780 if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
781
--- src/http.c
+++ src/http.c
@@ -727,10 +727,11 @@
727 fossil_strnicmp(zLine, "location:", 9)==0 ){
728 int i, j;
729 int wasHttps;
730 int wasProxy;
731 int priorUrlFlags;
732 UrlData target;
733
734 if ( --maxRedirect == 0){
735 if( (mHttpFlags & HTTP_QUIET)==0 ){
736 fossil_warning("redirect limit exceeded");
737 }
@@ -757,24 +758,27 @@
758 goto write_err;
759 }
760 wasHttps = g.url.isHttps;
761 wasProxy = g.url.useProxy;
762 priorUrlFlags = g.url.flags;
763 url_parse_local(&zLine[i], 0, &target);
764 if( wasHttps && !target.isHttps ){
765 if( (mHttpFlags & HTTP_QUIET)==0 ){
766 fossil_warning("cannot redirect from HTTPS to HTTP");
767 }
768 url_unparse(&target);
769 goto write_err;
770 }
771 if( target.isSsh || target.isFile ){
772 if( (mHttpFlags & HTTP_QUIET)==0 ){
773 fossil_warning("cannot redirect to %s", &zLine[i]);
774 }
775 url_unparse(&target);
776 goto write_err;
777 }
778 transport_close(&g.url);
779 g.url = target;
780 transport_global_shutdown(&g.url);
781 fSeenHttpAuth = 0;
782 if( g.zHttpAuth ) free(g.zHttpAuth);
783 g.zHttpAuth = get_httpauth();
784 if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
785

Keyboard Shortcuts

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