Fossil SCM
Found a workaround for the th1 puts escaping, but am still wondering whether it's a viable long-term solution.
Commit
18abb60d42333922b1286f4235eaecb90de3fadb59d326c3f77f3d8096dfb10e
Parent
8a4304eae23e796…
2 files changed
+41
-28
+8
-6
+41
-28
| --- src/pikchrshow.c | ||
| +++ src/pikchrshow.c | ||
| @@ -167,11 +167,11 @@ | ||
| 167 | 167 | builtin_fulfill_js_requests(); |
| 168 | 168 | style_footer(); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | static void pikchr_th_init(u32 fThInit){ |
| 172 | - Th_FossilInit(fThInit); | |
| 172 | + Th_FossilInit(fThInit & TH_INIT_MASK); | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /* |
| 176 | 176 | ** COMMAND: pikchr |
| 177 | 177 | ** |
| @@ -184,10 +184,13 @@ | ||
| 184 | 184 | ** |
| 185 | 185 | ** -th Process the input using TH1 before passing it to pikchr. |
| 186 | 186 | ** |
| 187 | 187 | ** -th-novar Disable $var and $<var> TH1 processing. Only applies |
| 188 | 188 | ** with the -th flag. |
| 189 | +** | |
| 190 | +** -th-nopic When using -th, output the post-TH1'd script | |
| 191 | +** instead of the pikchr-rendered output. | |
| 189 | 192 | ** |
| 190 | 193 | ** -th-trace Trace TH1 execution (for debugging purposes) |
| 191 | 194 | ** |
| 192 | 195 | ** TH1 Caveats: the built-in TH1 commands make some assumptions about |
| 193 | 196 | ** HTML escaping and output which do not apply via this |
| @@ -200,13 +203,14 @@ | ||
| 200 | 203 | Blob bOut = empty_blob; |
| 201 | 204 | const char * zInfile = "-"; |
| 202 | 205 | const char * zOutfile = "-"; |
| 203 | 206 | const int fWithDiv = find_option("div",0,0)!=0; |
| 204 | 207 | const int fTh1 = find_option("th",0,0)!=0; |
| 205 | - const int fNoVar = find_option("th-novar",0,0)!=0; | |
| 208 | + const int fNoPic = find_option("th-nopic",0,0)!=0; | |
| 206 | 209 | int isErr = 0; |
| 207 | - u32 fThInit = TH_INIT_DEFAULT; | |
| 210 | + u32 fThFlags = TH_INIT_DEFAULT | TH_INIT_NO_ESC | |
| 211 | + | (find_option("th-novar",0,0)!=0 ? TH_R2B_NO_VARS : 0); | |
| 208 | 212 | |
| 209 | 213 | Th_InitTraceLog()/*processes -th-trace flag*/; |
| 210 | 214 | verify_all_options(); |
| 211 | 215 | if(g.argc>4){ |
| 212 | 216 | usage("?INFILE? ?OUTFILE?"); |
| @@ -218,44 +222,53 @@ | ||
| 218 | 222 | zOutfile = g.argv[3]; |
| 219 | 223 | } |
| 220 | 224 | blob_read_from_file(&bIn, zInfile, ExtFILE); |
| 221 | 225 | if(fTh1){ |
| 222 | 226 | Blob out = empty_blob; |
| 223 | - Blob * oldOut; | |
| 224 | 227 | db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0) |
| 225 | - /* ^^^ needed for certain functions to work */; | |
| 226 | - oldOut = Th_SetOutputBlob(&out); | |
| 227 | - pikchr_th_init(fThInit); | |
| 228 | - isErr = Th_RenderToBlob(blob_str(&bIn), &out, | |
| 229 | - fNoVar ? TH_R2B_NO_VARS : 0); | |
| 230 | - blob_reset(&bIn); | |
| 231 | - bIn = out; | |
| 232 | - Th_SetOutputBlob(oldOut); | |
| 233 | - /*fossil_print("th'd:\n%b\n", &bIn);*/ | |
| 228 | + /* ^^^ needed for certain TH1 functions to work */; | |
| 229 | + pikchr_th_init(fThFlags); | |
| 230 | + isErr = Th_RenderToBlob(blob_str(&bIn), &out, fThFlags) ? 1 : 0; | |
| 231 | + if(isErr){ | |
| 232 | + blob_reset(&bOut); | |
| 233 | + bOut = out; | |
| 234 | + }else{ | |
| 235 | + blob_reset(&bIn); | |
| 236 | + bIn = out; | |
| 237 | + } | |
| 234 | 238 | } |
| 235 | 239 | if(!isErr){ |
| 236 | - int w = 0, h = 0; | |
| 237 | - const char * zContent = blob_str(&bIn); | |
| 238 | - char *zOut = pikchr(zContent, "pikchr", 0, &w, &h); | |
| 239 | - if( w>0 && h>0 ){ | |
| 240 | - if(fWithDiv){ | |
| 241 | - blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w); | |
| 242 | - } | |
| 243 | - blob_append(&bOut, zOut, -1); | |
| 244 | - if(fWithDiv){ | |
| 245 | - blob_append(&bOut,"</div>\n", 7); | |
| 246 | - } | |
| 240 | + if(fTh1 && fNoPic){ | |
| 241 | + bOut = bIn; | |
| 242 | + bIn = empty_blob; | |
| 247 | 243 | }else{ |
| 248 | - isErr = 1; | |
| 249 | - blob_append(&bOut, zOut, -1); | |
| 244 | + int w = 0, h = 0; | |
| 245 | + const char * zContent = blob_str(&bIn); | |
| 246 | + char *zOut; | |
| 247 | + | |
| 248 | + zOut = pikchr(zContent, "pikchr", 0, &w, &h); | |
| 249 | + if( w>0 && h>0 ){ | |
| 250 | + if(fWithDiv){ | |
| 251 | + blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w); | |
| 252 | + } | |
| 253 | + blob_append(&bOut, zOut, -1); | |
| 254 | + if(fWithDiv){ | |
| 255 | + blob_append(&bOut,"</div>\n", 7); | |
| 256 | + } | |
| 257 | + }else{ | |
| 258 | + isErr = 2; | |
| 259 | + blob_append(&bOut, zOut, -1); | |
| 260 | + } | |
| 261 | + fossil_free(zOut); | |
| 250 | 262 | } |
| 251 | - fossil_free(zOut); | |
| 252 | 263 | } |
| 253 | 264 | if(isErr){ |
| 254 | - fossil_fatal("ERROR: %b", &bOut); | |
| 265 | + /*fossil_print("ERROR: raw input:\n%b\n", &bIn);*/ | |
| 266 | + fossil_fatal("%s ERROR: %b", 1==isErr ? "TH1" : "pikchr", | |
| 267 | + &bOut); | |
| 255 | 268 | }else{ |
| 256 | 269 | blob_write_to_file(&bOut, zOutfile); |
| 257 | 270 | } |
| 258 | 271 | Th_PrintTraceLog(); |
| 259 | 272 | blob_reset(&bIn); |
| 260 | 273 | blob_reset(&bOut); |
| 261 | 274 | } |
| 262 | 275 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | builtin_fulfill_js_requests(); |
| 168 | style_footer(); |
| 169 | } |
| 170 | |
| 171 | static void pikchr_th_init(u32 fThInit){ |
| 172 | Th_FossilInit(fThInit); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | ** COMMAND: pikchr |
| 177 | ** |
| @@ -184,10 +184,13 @@ | |
| 184 | ** |
| 185 | ** -th Process the input using TH1 before passing it to pikchr. |
| 186 | ** |
| 187 | ** -th-novar Disable $var and $<var> TH1 processing. Only applies |
| 188 | ** with the -th flag. |
| 189 | ** |
| 190 | ** -th-trace Trace TH1 execution (for debugging purposes) |
| 191 | ** |
| 192 | ** TH1 Caveats: the built-in TH1 commands make some assumptions about |
| 193 | ** HTML escaping and output which do not apply via this |
| @@ -200,13 +203,14 @@ | |
| 200 | Blob bOut = empty_blob; |
| 201 | const char * zInfile = "-"; |
| 202 | const char * zOutfile = "-"; |
| 203 | const int fWithDiv = find_option("div",0,0)!=0; |
| 204 | const int fTh1 = find_option("th",0,0)!=0; |
| 205 | const int fNoVar = find_option("th-novar",0,0)!=0; |
| 206 | int isErr = 0; |
| 207 | u32 fThInit = TH_INIT_DEFAULT; |
| 208 | |
| 209 | Th_InitTraceLog()/*processes -th-trace flag*/; |
| 210 | verify_all_options(); |
| 211 | if(g.argc>4){ |
| 212 | usage("?INFILE? ?OUTFILE?"); |
| @@ -218,44 +222,53 @@ | |
| 218 | zOutfile = g.argv[3]; |
| 219 | } |
| 220 | blob_read_from_file(&bIn, zInfile, ExtFILE); |
| 221 | if(fTh1){ |
| 222 | Blob out = empty_blob; |
| 223 | Blob * oldOut; |
| 224 | db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0) |
| 225 | /* ^^^ needed for certain functions to work */; |
| 226 | oldOut = Th_SetOutputBlob(&out); |
| 227 | pikchr_th_init(fThInit); |
| 228 | isErr = Th_RenderToBlob(blob_str(&bIn), &out, |
| 229 | fNoVar ? TH_R2B_NO_VARS : 0); |
| 230 | blob_reset(&bIn); |
| 231 | bIn = out; |
| 232 | Th_SetOutputBlob(oldOut); |
| 233 | /*fossil_print("th'd:\n%b\n", &bIn);*/ |
| 234 | } |
| 235 | if(!isErr){ |
| 236 | int w = 0, h = 0; |
| 237 | const char * zContent = blob_str(&bIn); |
| 238 | char *zOut = pikchr(zContent, "pikchr", 0, &w, &h); |
| 239 | if( w>0 && h>0 ){ |
| 240 | if(fWithDiv){ |
| 241 | blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w); |
| 242 | } |
| 243 | blob_append(&bOut, zOut, -1); |
| 244 | if(fWithDiv){ |
| 245 | blob_append(&bOut,"</div>\n", 7); |
| 246 | } |
| 247 | }else{ |
| 248 | isErr = 1; |
| 249 | blob_append(&bOut, zOut, -1); |
| 250 | } |
| 251 | fossil_free(zOut); |
| 252 | } |
| 253 | if(isErr){ |
| 254 | fossil_fatal("ERROR: %b", &bOut); |
| 255 | }else{ |
| 256 | blob_write_to_file(&bOut, zOutfile); |
| 257 | } |
| 258 | Th_PrintTraceLog(); |
| 259 | blob_reset(&bIn); |
| 260 | blob_reset(&bOut); |
| 261 | } |
| 262 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | builtin_fulfill_js_requests(); |
| 168 | style_footer(); |
| 169 | } |
| 170 | |
| 171 | static void pikchr_th_init(u32 fThInit){ |
| 172 | Th_FossilInit(fThInit & TH_INIT_MASK); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | ** COMMAND: pikchr |
| 177 | ** |
| @@ -184,10 +184,13 @@ | |
| 184 | ** |
| 185 | ** -th Process the input using TH1 before passing it to pikchr. |
| 186 | ** |
| 187 | ** -th-novar Disable $var and $<var> TH1 processing. Only applies |
| 188 | ** with the -th flag. |
| 189 | ** |
| 190 | ** -th-nopic When using -th, output the post-TH1'd script |
| 191 | ** instead of the pikchr-rendered output. |
| 192 | ** |
| 193 | ** -th-trace Trace TH1 execution (for debugging purposes) |
| 194 | ** |
| 195 | ** TH1 Caveats: the built-in TH1 commands make some assumptions about |
| 196 | ** HTML escaping and output which do not apply via this |
| @@ -200,13 +203,14 @@ | |
| 203 | Blob bOut = empty_blob; |
| 204 | const char * zInfile = "-"; |
| 205 | const char * zOutfile = "-"; |
| 206 | const int fWithDiv = find_option("div",0,0)!=0; |
| 207 | const int fTh1 = find_option("th",0,0)!=0; |
| 208 | const int fNoPic = find_option("th-nopic",0,0)!=0; |
| 209 | int isErr = 0; |
| 210 | u32 fThFlags = TH_INIT_DEFAULT | TH_INIT_NO_ESC |
| 211 | | (find_option("th-novar",0,0)!=0 ? TH_R2B_NO_VARS : 0); |
| 212 | |
| 213 | Th_InitTraceLog()/*processes -th-trace flag*/; |
| 214 | verify_all_options(); |
| 215 | if(g.argc>4){ |
| 216 | usage("?INFILE? ?OUTFILE?"); |
| @@ -218,44 +222,53 @@ | |
| 222 | zOutfile = g.argv[3]; |
| 223 | } |
| 224 | blob_read_from_file(&bIn, zInfile, ExtFILE); |
| 225 | if(fTh1){ |
| 226 | Blob out = empty_blob; |
| 227 | db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0) |
| 228 | /* ^^^ needed for certain TH1 functions to work */; |
| 229 | pikchr_th_init(fThFlags); |
| 230 | isErr = Th_RenderToBlob(blob_str(&bIn), &out, fThFlags) ? 1 : 0; |
| 231 | if(isErr){ |
| 232 | blob_reset(&bOut); |
| 233 | bOut = out; |
| 234 | }else{ |
| 235 | blob_reset(&bIn); |
| 236 | bIn = out; |
| 237 | } |
| 238 | } |
| 239 | if(!isErr){ |
| 240 | if(fTh1 && fNoPic){ |
| 241 | bOut = bIn; |
| 242 | bIn = empty_blob; |
| 243 | }else{ |
| 244 | int w = 0, h = 0; |
| 245 | const char * zContent = blob_str(&bIn); |
| 246 | char *zOut; |
| 247 | |
| 248 | zOut = pikchr(zContent, "pikchr", 0, &w, &h); |
| 249 | if( w>0 && h>0 ){ |
| 250 | if(fWithDiv){ |
| 251 | blob_appendf(&bOut,"<div style='max-width:%dpx;'>\n", w); |
| 252 | } |
| 253 | blob_append(&bOut, zOut, -1); |
| 254 | if(fWithDiv){ |
| 255 | blob_append(&bOut,"</div>\n", 7); |
| 256 | } |
| 257 | }else{ |
| 258 | isErr = 2; |
| 259 | blob_append(&bOut, zOut, -1); |
| 260 | } |
| 261 | fossil_free(zOut); |
| 262 | } |
| 263 | } |
| 264 | if(isErr){ |
| 265 | /*fossil_print("ERROR: raw input:\n%b\n", &bIn);*/ |
| 266 | fossil_fatal("%s ERROR: %b", 1==isErr ? "TH1" : "pikchr", |
| 267 | &bOut); |
| 268 | }else{ |
| 269 | blob_write_to_file(&bOut, zOutfile); |
| 270 | } |
| 271 | Th_PrintTraceLog(); |
| 272 | blob_reset(&bIn); |
| 273 | blob_reset(&bOut); |
| 274 | } |
| 275 |
+8
-6
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -31,11 +31,12 @@ | ||
| 31 | 31 | #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ |
| 32 | 32 | #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ |
| 33 | 33 | #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */ |
| 34 | 34 | #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ |
| 35 | 35 | #define TH_INIT_NO_REPO ((u32)0x00000010) /* Skip opening repository. */ |
| 36 | -#define TH_INIT_MASK ((u32)0x0000001F) /* All possible init flags. */ | |
| 36 | +#define TH_INIT_NO_ESC ((u32)0x00000020) /* Do not html-escape certain output. */ | |
| 37 | +#define TH_INIT_MASK ((u32)0x0000003F) /* All possible init flags. */ | |
| 37 | 38 | |
| 38 | 39 | /* |
| 39 | 40 | ** Useful and/or "well-known" combinations of flag values. |
| 40 | 41 | */ |
| 41 | 42 | #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */ |
| @@ -471,14 +472,16 @@ | ||
| 471 | 472 | void *pConvert, |
| 472 | 473 | int argc, |
| 473 | 474 | const char **argv, |
| 474 | 475 | int *argl |
| 475 | 476 | ){ |
| 477 | + unsigned int doEscape = (TH_INIT_NO_ESC & g.th1Flags) | |
| 478 | + ? 0U : *(unsigned int*)pConvert; | |
| 476 | 479 | if( argc!=2 ){ |
| 477 | 480 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 478 | 481 | } |
| 479 | - sendText(0,(char*)argv[1], argl[1], *(unsigned int*)pConvert); | |
| 482 | + sendText(0,(char*)argv[1], argl[1], doEscape); | |
| 480 | 483 | return TH_OK; |
| 481 | 484 | } |
| 482 | 485 | |
| 483 | 486 | /* |
| 484 | 487 | ** TH1 command: redirect URL ?withMethod? |
| @@ -2138,11 +2141,11 @@ | ||
| 2138 | 2141 | int needConfig = flags & TH_INIT_NEED_CONFIG; |
| 2139 | 2142 | int forceReset = flags & TH_INIT_FORCE_RESET; |
| 2140 | 2143 | int forceTcl = flags & TH_INIT_FORCE_TCL; |
| 2141 | 2144 | int forceSetup = flags & TH_INIT_FORCE_SETUP; |
| 2142 | 2145 | int noRepo = flags & TH_INIT_NO_REPO; |
| 2143 | - static unsigned int aFlags[] = { 0, 1, WIKI_LINKSONLY }; | |
| 2146 | + static unsigned int aFlags[] = {0, 1, WIKI_LINKSONLY }; | |
| 2144 | 2147 | static int anonFlag = LOGIN_ANON; |
| 2145 | 2148 | static int zeroInt = 0; |
| 2146 | 2149 | static struct _Command { |
| 2147 | 2150 | const char *zName; |
| 2148 | 2151 | Th_CommandProc xProc; |
| @@ -2654,14 +2657,13 @@ | ||
| 2654 | 2657 | int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){ |
| 2655 | 2658 | int i = 0; |
| 2656 | 2659 | int n; |
| 2657 | 2660 | int rc = TH_OK; |
| 2658 | 2661 | char *zResult; |
| 2659 | - Blob * const origOut = pThOut; | |
| 2662 | + Blob * const origOut = Th_SetOutputBlob(pOut); | |
| 2660 | 2663 | |
| 2661 | 2664 | assert(0==(TH_R2B_MASK & TH_INIT_MASK) && "init/r2b mask conflict"); |
| 2662 | - pThOut = pOut; | |
| 2663 | 2665 | Th_FossilInit(mFlags & TH_INIT_MASK); |
| 2664 | 2666 | while( z[i] ){ |
| 2665 | 2667 | if( !(TH_R2B_NO_VARS & mFlags) |
| 2666 | 2668 | && z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){ |
| 2667 | 2669 | const char *zVar; |
| @@ -2709,11 +2711,11 @@ | ||
| 2709 | 2711 | zResult = (char*)Th_GetResult(g.interp, &n); |
| 2710 | 2712 | sendError(pOut,zResult, n, 1); |
| 2711 | 2713 | }else{ |
| 2712 | 2714 | sendText(pOut,z, i, 0); |
| 2713 | 2715 | } |
| 2714 | - pThOut = origOut; | |
| 2716 | + Th_SetOutputBlob(origOut); | |
| 2715 | 2717 | return rc; |
| 2716 | 2718 | } |
| 2717 | 2719 | |
| 2718 | 2720 | /* |
| 2719 | 2721 | ** The z[] input contains text mixed with TH1 scripts. |
| 2720 | 2722 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -31,11 +31,12 @@ | |
| 31 | #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ |
| 32 | #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ |
| 33 | #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */ |
| 34 | #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ |
| 35 | #define TH_INIT_NO_REPO ((u32)0x00000010) /* Skip opening repository. */ |
| 36 | #define TH_INIT_MASK ((u32)0x0000001F) /* All possible init flags. */ |
| 37 | |
| 38 | /* |
| 39 | ** Useful and/or "well-known" combinations of flag values. |
| 40 | */ |
| 41 | #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */ |
| @@ -471,14 +472,16 @@ | |
| 471 | void *pConvert, |
| 472 | int argc, |
| 473 | const char **argv, |
| 474 | int *argl |
| 475 | ){ |
| 476 | if( argc!=2 ){ |
| 477 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 478 | } |
| 479 | sendText(0,(char*)argv[1], argl[1], *(unsigned int*)pConvert); |
| 480 | return TH_OK; |
| 481 | } |
| 482 | |
| 483 | /* |
| 484 | ** TH1 command: redirect URL ?withMethod? |
| @@ -2138,11 +2141,11 @@ | |
| 2138 | int needConfig = flags & TH_INIT_NEED_CONFIG; |
| 2139 | int forceReset = flags & TH_INIT_FORCE_RESET; |
| 2140 | int forceTcl = flags & TH_INIT_FORCE_TCL; |
| 2141 | int forceSetup = flags & TH_INIT_FORCE_SETUP; |
| 2142 | int noRepo = flags & TH_INIT_NO_REPO; |
| 2143 | static unsigned int aFlags[] = { 0, 1, WIKI_LINKSONLY }; |
| 2144 | static int anonFlag = LOGIN_ANON; |
| 2145 | static int zeroInt = 0; |
| 2146 | static struct _Command { |
| 2147 | const char *zName; |
| 2148 | Th_CommandProc xProc; |
| @@ -2654,14 +2657,13 @@ | |
| 2654 | int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){ |
| 2655 | int i = 0; |
| 2656 | int n; |
| 2657 | int rc = TH_OK; |
| 2658 | char *zResult; |
| 2659 | Blob * const origOut = pThOut; |
| 2660 | |
| 2661 | assert(0==(TH_R2B_MASK & TH_INIT_MASK) && "init/r2b mask conflict"); |
| 2662 | pThOut = pOut; |
| 2663 | Th_FossilInit(mFlags & TH_INIT_MASK); |
| 2664 | while( z[i] ){ |
| 2665 | if( !(TH_R2B_NO_VARS & mFlags) |
| 2666 | && z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){ |
| 2667 | const char *zVar; |
| @@ -2709,11 +2711,11 @@ | |
| 2709 | zResult = (char*)Th_GetResult(g.interp, &n); |
| 2710 | sendError(pOut,zResult, n, 1); |
| 2711 | }else{ |
| 2712 | sendText(pOut,z, i, 0); |
| 2713 | } |
| 2714 | pThOut = origOut; |
| 2715 | return rc; |
| 2716 | } |
| 2717 | |
| 2718 | /* |
| 2719 | ** The z[] input contains text mixed with TH1 scripts. |
| 2720 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -31,11 +31,12 @@ | |
| 31 | #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ |
| 32 | #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ |
| 33 | #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */ |
| 34 | #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ |
| 35 | #define TH_INIT_NO_REPO ((u32)0x00000010) /* Skip opening repository. */ |
| 36 | #define TH_INIT_NO_ESC ((u32)0x00000020) /* Do not html-escape certain output. */ |
| 37 | #define TH_INIT_MASK ((u32)0x0000003F) /* All possible init flags. */ |
| 38 | |
| 39 | /* |
| 40 | ** Useful and/or "well-known" combinations of flag values. |
| 41 | */ |
| 42 | #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */ |
| @@ -471,14 +472,16 @@ | |
| 472 | void *pConvert, |
| 473 | int argc, |
| 474 | const char **argv, |
| 475 | int *argl |
| 476 | ){ |
| 477 | unsigned int doEscape = (TH_INIT_NO_ESC & g.th1Flags) |
| 478 | ? 0U : *(unsigned int*)pConvert; |
| 479 | if( argc!=2 ){ |
| 480 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 481 | } |
| 482 | sendText(0,(char*)argv[1], argl[1], doEscape); |
| 483 | return TH_OK; |
| 484 | } |
| 485 | |
| 486 | /* |
| 487 | ** TH1 command: redirect URL ?withMethod? |
| @@ -2138,11 +2141,11 @@ | |
| 2141 | int needConfig = flags & TH_INIT_NEED_CONFIG; |
| 2142 | int forceReset = flags & TH_INIT_FORCE_RESET; |
| 2143 | int forceTcl = flags & TH_INIT_FORCE_TCL; |
| 2144 | int forceSetup = flags & TH_INIT_FORCE_SETUP; |
| 2145 | int noRepo = flags & TH_INIT_NO_REPO; |
| 2146 | static unsigned int aFlags[] = {0, 1, WIKI_LINKSONLY }; |
| 2147 | static int anonFlag = LOGIN_ANON; |
| 2148 | static int zeroInt = 0; |
| 2149 | static struct _Command { |
| 2150 | const char *zName; |
| 2151 | Th_CommandProc xProc; |
| @@ -2654,14 +2657,13 @@ | |
| 2657 | int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){ |
| 2658 | int i = 0; |
| 2659 | int n; |
| 2660 | int rc = TH_OK; |
| 2661 | char *zResult; |
| 2662 | Blob * const origOut = Th_SetOutputBlob(pOut); |
| 2663 | |
| 2664 | assert(0==(TH_R2B_MASK & TH_INIT_MASK) && "init/r2b mask conflict"); |
| 2665 | Th_FossilInit(mFlags & TH_INIT_MASK); |
| 2666 | while( z[i] ){ |
| 2667 | if( !(TH_R2B_NO_VARS & mFlags) |
| 2668 | && z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){ |
| 2669 | const char *zVar; |
| @@ -2709,11 +2711,11 @@ | |
| 2711 | zResult = (char*)Th_GetResult(g.interp, &n); |
| 2712 | sendError(pOut,zResult, n, 1); |
| 2713 | }else{ |
| 2714 | sendText(pOut,z, i, 0); |
| 2715 | } |
| 2716 | Th_SetOutputBlob(origOut); |
| 2717 | return rc; |
| 2718 | } |
| 2719 | |
| 2720 | /* |
| 2721 | ** The z[] input contains text mixed with TH1 scripts. |
| 2722 |