Fossil SCM

Make the TH1 http command check for an http: or https: URL before parsing it, so that any other argument is a script error and does not end the process with "unknown repository".

dmestas 2026-11-22 11:36 UTC small-fixes
Commit 4a5d3e9c96e5531745ec01f710a652d0269341961baf04ac9c74ae23c35c2609
1 file changed +5 -3
+5 -3
--- src/th_main.c
+++ src/th_main.c
@@ -2222,16 +2222,18 @@
22222222
}
22232223
if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
22242224
if( nArg+1!=argc && nArg+2!=argc ){
22252225
return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
22262226
}
2227
- memset(&urlData, '\0', sizeof(urlData));
2228
- url_parse_local(argv[nArg], 0, &urlData);
2229
- if( urlData.isSsh || urlData.isFile ){
2227
+ if( fossil_strnicmp(argv[nArg], "http://", 7)!=0
2228
+ && fossil_strnicmp(argv[nArg], "https://", 8)!=0
2229
+ ){
22302230
Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
22312231
return TH_ERROR;
22322232
}
2233
+ memset(&urlData, '\0', sizeof(urlData));
2234
+ url_parse_local(argv[nArg], 0, &urlData);
22332235
zRegexp = db_get("th1-uri-regexp", 0);
22342236
if( zRegexp && zRegexp[0] ){
22352237
const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
22362238
if( zErr ){
22372239
Th_SetResult(interp, zErr, -1);
22382240
--- src/th_main.c
+++ src/th_main.c
@@ -2222,16 +2222,18 @@
2222 }
2223 if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2224 if( nArg+1!=argc && nArg+2!=argc ){
2225 return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
2226 }
2227 memset(&urlData, '\0', sizeof(urlData));
2228 url_parse_local(argv[nArg], 0, &urlData);
2229 if( urlData.isSsh || urlData.isFile ){
2230 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
2231 return TH_ERROR;
2232 }
 
 
2233 zRegexp = db_get("th1-uri-regexp", 0);
2234 if( zRegexp && zRegexp[0] ){
2235 const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
2236 if( zErr ){
2237 Th_SetResult(interp, zErr, -1);
2238
--- src/th_main.c
+++ src/th_main.c
@@ -2222,16 +2222,18 @@
2222 }
2223 if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2224 if( nArg+1!=argc && nArg+2!=argc ){
2225 return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
2226 }
2227 if( fossil_strnicmp(argv[nArg], "http://", 7)!=0
2228 && fossil_strnicmp(argv[nArg], "https://", 8)!=0
2229 ){
2230 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
2231 return TH_ERROR;
2232 }
2233 memset(&urlData, '\0', sizeof(urlData));
2234 url_parse_local(argv[nArg], 0, &urlData);
2235 zRegexp = db_get("th1-uri-regexp", 0);
2236 if( zRegexp && zRegexp[0] ){
2237 const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
2238 if( zErr ){
2239 Th_SetResult(interp, zErr, -1);
2240

Keyboard Shortcuts

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