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".
Commit
4a5d3e9c96e5531745ec01f710a652d0269341961baf04ac9c74ae23c35c2609
Parent
1ef35bf12c008c4…
1 file changed
+5
-3
+5
-3
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -2222,16 +2222,18 @@ | ||
| 2222 | 2222 | } |
| 2223 | 2223 | if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++; |
| 2224 | 2224 | if( nArg+1!=argc && nArg+2!=argc ){ |
| 2225 | 2225 | return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS); |
| 2226 | 2226 | } |
| 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 | + ){ | |
| 2230 | 2230 | Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0); |
| 2231 | 2231 | return TH_ERROR; |
| 2232 | 2232 | } |
| 2233 | + memset(&urlData, '\0', sizeof(urlData)); | |
| 2234 | + url_parse_local(argv[nArg], 0, &urlData); | |
| 2233 | 2235 | zRegexp = db_get("th1-uri-regexp", 0); |
| 2234 | 2236 | if( zRegexp && zRegexp[0] ){ |
| 2235 | 2237 | const char *zErr = fossil_re_compile(&pRe, zRegexp, 0); |
| 2236 | 2238 | if( zErr ){ |
| 2237 | 2239 | Th_SetResult(interp, zErr, -1); |
| 2238 | 2240 |
| --- 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 |