Fossil SCM

Ensure that <var>$requested_page</var> is always initialized. This is a follow-up to [c68fa2edd76d90] that fixes a bug in [b05a6c6bc826d3].

george 2022-05-11 21:23 trunk
Commit a44e3c7338d205aa92544c6bca246be1e3aee6ed1ef73ce4825b42a1c6339bb4
2 files changed +1 -1 +7 -5
+1 -1
--- src/main.c
+++ src/main.c
@@ -177,11 +177,11 @@
177177
int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
178178
char *zSshCmd; /* SSH command string */
179179
const char *zHttpCmd; /* External program to do HTTP requests */
180180
int fNoSync; /* Do not do an autosync ever. --nosync */
181181
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) */
183183
char *zExtra; /* Extra path information past the webpage name */
184184
char *zBaseURL; /* Full text of the URL being served */
185185
char *zHttpsURL; /* zBaseURL translated to https: */
186186
char *zTop; /* Parent directory of zPath */
187187
int nExtraURL; /* Extra bytes added to SCRIPT_NAME */
188188
--- 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 @@
749749
/*
750750
** Initialize all the default TH1 variables
751751
*/
752752
static void style_init_th1_vars(const char *zTitle){
753753
const char *zNonce = style_nonce();
754
- char *zDfltCsp, *zSlash = 0;
754
+ char *zDfltCsp;
755755
756756
zDfltCsp = style_csp(1);
757757
/*
758758
** Do not overwrite the TH1 variable "default_csp" if it exists, as this
759759
** allows it to be properly overridden via the TH1 setup script (i.e. it
@@ -769,15 +769,17 @@
769769
Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
770770
Th_Store("home", g.zTop);
771771
Th_Store("index_page", db_get("index-page","/home"));
772772
if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath);
773773
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 */
777777
Th_Store("requested_page", escape_quotes(g.zPath));
778
- *zSlash = '/';
778
+ if( pSlash ) *pSlash = '/';
779
+ }else{
780
+ Th_Store("requested_page", "");
779781
}
780782
Th_Store("canonical_page", escape_quotes(g.zPhase+1));
781783
Th_Store("csrf_token", g.zCsrfToken);
782784
Th_Store("release_version", RELEASE_VERSION);
783785
Th_Store("manifest_version", MANIFEST_VERSION);
784786
--- 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

Keyboard Shortcuts

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