Fossil SCM
Ensure that <var>$requested_page</var> is always initialized. This is a follow-up to [c68fa2edd76d90] that fixes a bug in [b05a6c6bc826d3].
Commit
a44e3c7338d205aa92544c6bca246be1e3aee6ed1ef73ce4825b42a1c6339bb4
Parent
a791d5e8058b328…
2 files changed
+1
-1
+7
-5
+1
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -177,11 +177,11 @@ | ||
| 177 | 177 | int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */ |
| 178 | 178 | char *zSshCmd; /* SSH command string */ |
| 179 | 179 | const char *zHttpCmd; /* External program to do HTTP requests */ |
| 180 | 180 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 181 | 181 | int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ |
| 182 | - char *zPath; /* Name of webpage being served */ | |
| 182 | + char *zPath; /* Name of webpage being served (may be NULL) */ | |
| 183 | 183 | char *zExtra; /* Extra path information past the webpage name */ |
| 184 | 184 | char *zBaseURL; /* Full text of the URL being served */ |
| 185 | 185 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 186 | 186 | char *zTop; /* Parent directory of zPath */ |
| 187 | 187 | int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ |
| 188 | 188 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -177,11 +177,11 @@ | |
| 177 | int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */ |
| 178 | char *zSshCmd; /* SSH command string */ |
| 179 | const char *zHttpCmd; /* External program to do HTTP requests */ |
| 180 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 181 | int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ |
| 182 | char *zPath; /* Name of webpage being served */ |
| 183 | char *zExtra; /* Extra path information past the webpage name */ |
| 184 | char *zBaseURL; /* Full text of the URL being served */ |
| 185 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 186 | char *zTop; /* Parent directory of zPath */ |
| 187 | int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ |
| 188 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -177,11 +177,11 @@ | |
| 177 | int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */ |
| 178 | char *zSshCmd; /* SSH command string */ |
| 179 | const char *zHttpCmd; /* External program to do HTTP requests */ |
| 180 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 181 | int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ |
| 182 | char *zPath; /* Name of webpage being served (may be NULL) */ |
| 183 | char *zExtra; /* Extra path information past the webpage name */ |
| 184 | char *zBaseURL; /* Full text of the URL being served */ |
| 185 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 186 | char *zTop; /* Parent directory of zPath */ |
| 187 | int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ |
| 188 |
+7
-5
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -749,11 +749,11 @@ | ||
| 749 | 749 | /* |
| 750 | 750 | ** Initialize all the default TH1 variables |
| 751 | 751 | */ |
| 752 | 752 | static void style_init_th1_vars(const char *zTitle){ |
| 753 | 753 | const char *zNonce = style_nonce(); |
| 754 | - char *zDfltCsp, *zSlash = 0; | |
| 754 | + char *zDfltCsp; | |
| 755 | 755 | |
| 756 | 756 | zDfltCsp = style_csp(1); |
| 757 | 757 | /* |
| 758 | 758 | ** Do not overwrite the TH1 variable "default_csp" if it exists, as this |
| 759 | 759 | ** allows it to be properly overridden via the TH1 setup script (i.e. it |
| @@ -769,15 +769,17 @@ | ||
| 769 | 769 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 770 | 770 | Th_Store("home", g.zTop); |
| 771 | 771 | Th_Store("index_page", db_get("index-page","/home")); |
| 772 | 772 | if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath); |
| 773 | 773 | Th_Store("current_page", local_zCurrentPage); |
| 774 | - /* store the first segment of a path; make a temporary cut if necessary */ | |
| 775 | - if( g.zPath && (zSlash = strchr(g.zPath,'/'))!=0 ){ | |
| 776 | - *zSlash = 0; | |
| 774 | + if( g.zPath ){ /* store the first segment of a path; */ | |
| 775 | + char *pSlash = strchr(g.zPath,'/'); | |
| 776 | + if( pSlash ) *pSlash = 0; /* make a temporary cut if necessary */ | |
| 777 | 777 | Th_Store("requested_page", escape_quotes(g.zPath)); |
| 778 | - *zSlash = '/'; | |
| 778 | + if( pSlash ) *pSlash = '/'; | |
| 779 | + }else{ | |
| 780 | + Th_Store("requested_page", ""); | |
| 779 | 781 | } |
| 780 | 782 | Th_Store("canonical_page", escape_quotes(g.zPhase+1)); |
| 781 | 783 | Th_Store("csrf_token", g.zCsrfToken); |
| 782 | 784 | Th_Store("release_version", RELEASE_VERSION); |
| 783 | 785 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 784 | 786 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -749,11 +749,11 @@ | |
| 749 | /* |
| 750 | ** Initialize all the default TH1 variables |
| 751 | */ |
| 752 | static void style_init_th1_vars(const char *zTitle){ |
| 753 | const char *zNonce = style_nonce(); |
| 754 | char *zDfltCsp, *zSlash = 0; |
| 755 | |
| 756 | zDfltCsp = style_csp(1); |
| 757 | /* |
| 758 | ** Do not overwrite the TH1 variable "default_csp" if it exists, as this |
| 759 | ** allows it to be properly overridden via the TH1 setup script (i.e. it |
| @@ -769,15 +769,17 @@ | |
| 769 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 770 | Th_Store("home", g.zTop); |
| 771 | Th_Store("index_page", db_get("index-page","/home")); |
| 772 | if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath); |
| 773 | Th_Store("current_page", local_zCurrentPage); |
| 774 | /* store the first segment of a path; make a temporary cut if necessary */ |
| 775 | if( g.zPath && (zSlash = strchr(g.zPath,'/'))!=0 ){ |
| 776 | *zSlash = 0; |
| 777 | Th_Store("requested_page", escape_quotes(g.zPath)); |
| 778 | *zSlash = '/'; |
| 779 | } |
| 780 | Th_Store("canonical_page", escape_quotes(g.zPhase+1)); |
| 781 | Th_Store("csrf_token", g.zCsrfToken); |
| 782 | Th_Store("release_version", RELEASE_VERSION); |
| 783 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 784 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -749,11 +749,11 @@ | |
| 749 | /* |
| 750 | ** Initialize all the default TH1 variables |
| 751 | */ |
| 752 | static void style_init_th1_vars(const char *zTitle){ |
| 753 | const char *zNonce = style_nonce(); |
| 754 | char *zDfltCsp; |
| 755 | |
| 756 | zDfltCsp = style_csp(1); |
| 757 | /* |
| 758 | ** Do not overwrite the TH1 variable "default_csp" if it exists, as this |
| 759 | ** allows it to be properly overridden via the TH1 setup script (i.e. it |
| @@ -769,15 +769,17 @@ | |
| 769 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 770 | Th_Store("home", g.zTop); |
| 771 | Th_Store("index_page", db_get("index-page","/home")); |
| 772 | if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath); |
| 773 | Th_Store("current_page", local_zCurrentPage); |
| 774 | if( g.zPath ){ /* store the first segment of a path; */ |
| 775 | char *pSlash = strchr(g.zPath,'/'); |
| 776 | if( pSlash ) *pSlash = 0; /* make a temporary cut if necessary */ |
| 777 | Th_Store("requested_page", escape_quotes(g.zPath)); |
| 778 | if( pSlash ) *pSlash = '/'; |
| 779 | }else{ |
| 780 | Th_Store("requested_page", ""); |
| 781 | } |
| 782 | Th_Store("canonical_page", escape_quotes(g.zPhase+1)); |
| 783 | Th_Store("csrf_token", g.zCsrfToken); |
| 784 | Th_Store("release_version", RELEASE_VERSION); |
| 785 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 786 |