Fossil SCM

When calling Th_Render() recursively, pass on g.th1Flags so that recursive calls do not inadvertently toggle flags like TH_INIT_NO_ENCODE.

stephan 2021-07-02 04:16 th1-recursive-render
Commit 0a57df7e07759dc8b8798fda1a96829ff2789cf57714dfdb2d4238f25a144dee
1 file changed +4 -2
+4 -2
--- src/th_main.c
+++ src/th_main.c
@@ -2918,20 +2918,22 @@
29182918
** This routine processes the template and writes the results to one
29192919
** of stdout, CGI, or an internal blob which was set up via a prior
29202920
** call to Th_SetOutputBlob().
29212921
*/
29222922
int Th_Render(const char *z){
2923
- return Th_RenderToBlob(z, pThOut, 0)
2923
+ return Th_RenderToBlob(z, pThOut, g.th1Flags)
29242924
/* Maintenance reminder: on most calls to Th_Render(), e.g. for
29252925
** outputing the site skin, pThOut will be 0, which means that
29262926
** Th_RenderToBlob() will output directly to the CGI buffer (in
29272927
** CGI mode) or stdout (in CLI mode). Recursive calls, however,
29282928
** e.g. via the "render" script function binding, need to use the
29292929
** pThOut blob in order to avoid out-of-order output if
29302930
** Th_SetOutputBlob() has been called. If it has not been called,
29312931
** pThOut will be 0, which will redirect the output to CGI/stdout,
2932
- ** as appropriate.
2932
+ ** as appropriate. We need to pass on g.th1Flags for the case of
2933
+ ** recursive calls, so that, e.g., TH_INIT_NO_ENCODE does not get
2934
+ ** inadvertently toggled off by a recursive call.
29332935
*/;
29342936
}
29352937
29362938
/*
29372939
** COMMAND: test-th-render
29382940
--- src/th_main.c
+++ src/th_main.c
@@ -2918,20 +2918,22 @@
2918 ** This routine processes the template and writes the results to one
2919 ** of stdout, CGI, or an internal blob which was set up via a prior
2920 ** call to Th_SetOutputBlob().
2921 */
2922 int Th_Render(const char *z){
2923 return Th_RenderToBlob(z, pThOut, 0)
2924 /* Maintenance reminder: on most calls to Th_Render(), e.g. for
2925 ** outputing the site skin, pThOut will be 0, which means that
2926 ** Th_RenderToBlob() will output directly to the CGI buffer (in
2927 ** CGI mode) or stdout (in CLI mode). Recursive calls, however,
2928 ** e.g. via the "render" script function binding, need to use the
2929 ** pThOut blob in order to avoid out-of-order output if
2930 ** Th_SetOutputBlob() has been called. If it has not been called,
2931 ** pThOut will be 0, which will redirect the output to CGI/stdout,
2932 ** as appropriate.
 
 
2933 */;
2934 }
2935
2936 /*
2937 ** COMMAND: test-th-render
2938
--- src/th_main.c
+++ src/th_main.c
@@ -2918,20 +2918,22 @@
2918 ** This routine processes the template and writes the results to one
2919 ** of stdout, CGI, or an internal blob which was set up via a prior
2920 ** call to Th_SetOutputBlob().
2921 */
2922 int Th_Render(const char *z){
2923 return Th_RenderToBlob(z, pThOut, g.th1Flags)
2924 /* Maintenance reminder: on most calls to Th_Render(), e.g. for
2925 ** outputing the site skin, pThOut will be 0, which means that
2926 ** Th_RenderToBlob() will output directly to the CGI buffer (in
2927 ** CGI mode) or stdout (in CLI mode). Recursive calls, however,
2928 ** e.g. via the "render" script function binding, need to use the
2929 ** pThOut blob in order to avoid out-of-order output if
2930 ** Th_SetOutputBlob() has been called. If it has not been called,
2931 ** pThOut will be 0, which will redirect the output to CGI/stdout,
2932 ** as appropriate. We need to pass on g.th1Flags for the case of
2933 ** recursive calls, so that, e.g., TH_INIT_NO_ENCODE does not get
2934 ** inadvertently toggled off by a recursive call.
2935 */;
2936 }
2937
2938 /*
2939 ** COMMAND: test-th-render
2940

Keyboard Shortcuts

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