| | @@ -289,10 +289,41 @@ |
| 289 | 289 | if( g.thTrace ){ |
| 290 | 290 | Th_Trace("enable_output {%.*s} -> %d<br />\n", argl[1],argv[1],enableOutput); |
| 291 | 291 | } |
| 292 | 292 | return rc; |
| 293 | 293 | } |
| 294 | + |
| 295 | +/* |
| 296 | +** TH1 command: enable_htmlify BOOLEAN |
| 297 | +** |
| 298 | +** Enable or disable the HTML escaping done by all output which |
| 299 | +** originates from TH1 (via sendText()). |
| 300 | +*/ |
| 301 | +static int enableHtmlifyCmd( |
| 302 | + Th_Interp *interp, |
| 303 | + void *p, |
| 304 | + int argc, |
| 305 | + const char **argv, |
| 306 | + int *argl |
| 307 | +){ |
| 308 | + int rc, buul; |
| 309 | + if( argc<2 || argc>3 ){ |
| 310 | + return Th_WrongNumArgs(interp, |
| 311 | + "enable_htmlify [TRACE_LABEL] BOOLEAN"); |
| 312 | + } |
| 313 | + rc = Th_ToInt(interp, argv[argc-1], argl[argc-1], &buul); |
| 314 | + if( g.thTrace ){ |
| 315 | + Th_Trace("enable_htmlify {%.*s} -> %d<br />\n", |
| 316 | + argl[1],argv[1],buul); |
| 317 | + } |
| 318 | + if(buul){ |
| 319 | + g.th1Flags &= ~TH_INIT_NO_ENCODE; |
| 320 | + }else{ |
| 321 | + g.th1Flags |= TH_INIT_NO_ENCODE; |
| 322 | + } |
| 323 | + return rc; |
| 324 | +} |
| 294 | 325 | |
| 295 | 326 | /* |
| 296 | 327 | ** Returns a name for a TH1 return code. |
| 297 | 328 | */ |
| 298 | 329 | const char *Th_ReturnCodeName(int rc, int nullIfOk){ |
| | @@ -2200,10 +2231,11 @@ |
| 2200 | 2231 | {"copybtn", copybtnCmd, 0}, |
| 2201 | 2232 | {"date", dateCmd, 0}, |
| 2202 | 2233 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 2203 | 2234 | {"defHeader", defHeaderCmd, 0}, |
| 2204 | 2235 | {"dir", dirCmd, 0}, |
| 2236 | + {"enable_htmlify",enableHtmlifyCmd, 0}, |
| 2205 | 2237 | {"enable_output", enableOutputCmd, 0}, |
| 2206 | 2238 | {"encode64", encode64Cmd, 0}, |
| 2207 | 2239 | {"getParameter", getParameterCmd, 0}, |
| 2208 | 2240 | {"glob_match", globMatchCmd, 0}, |
| 2209 | 2241 | {"globalState", globalStateCmd, 0}, |
| | @@ -2682,19 +2714,22 @@ |
| 2682 | 2714 | #if INTERFACE |
| 2683 | 2715 | /* |
| 2684 | 2716 | ** Flags for use with Th_RenderToBlob. These must not overlap with |
| 2685 | 2717 | ** TH_INIT_MASK. |
| 2686 | 2718 | */ |
| 2687 | | -#define TH_R2B_MASK ((u32)0xff0000) |
| 2688 | | -#define TH_R2B_NO_VARS ((u32)0x010000) /* Disables eval of $vars and $<vars> */ |
| 2719 | +#define TH_R2B_MASK ((u32)0x0f000) |
| 2720 | +#define TH_R2B_NO_VARS ((u32)0x01000) /* Disables eval of $vars and $<vars> */ |
| 2689 | 2721 | #endif |
| 2690 | 2722 | |
| 2691 | 2723 | /* |
| 2692 | 2724 | ** If pOut is NULL, this works identically to Th_Render(), else it |
| 2693 | 2725 | ** works just like that function but appends any TH1-generated output |
| 2694 | 2726 | ** to the given blob. A bitmask of TH_R2B_xxx and/or TH_INIT_xxx flags |
| 2695 | | -** may be passed as the 3rd argument, or 0 for default options. |
| 2727 | +** may be passed as the 3rd argument, or 0 for default options. Note |
| 2728 | +** that this function necessarily calls Th_FossilInit(), which may |
| 2729 | +** unset flags used on previous calls unless mFlags is explicitly |
| 2730 | +** passed in. |
| 2696 | 2731 | */ |
| 2697 | 2732 | int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){ |
| 2698 | 2733 | int i = 0; |
| 2699 | 2734 | int n; |
| 2700 | 2735 | int rc = TH_OK; |
| | @@ -2702,11 +2737,11 @@ |
| 2702 | 2737 | Blob * const origOut = Th_SetOutputBlob(pOut); |
| 2703 | 2738 | |
| 2704 | 2739 | assert(0==(TH_R2B_MASK & TH_INIT_MASK) && "init/r2b mask conflict"); |
| 2705 | 2740 | Th_FossilInit(mFlags & TH_INIT_MASK); |
| 2706 | 2741 | while( z[i] ){ |
| 2707 | | - if( !(TH_R2B_NO_VARS & mFlags) |
| 2742 | + if( 0!=(TH_R2B_NO_VARS & mFlags) |
| 2708 | 2743 | && z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){ |
| 2709 | 2744 | const char *zVar; |
| 2710 | 2745 | int nVar; |
| 2711 | 2746 | int encode = 1; |
| 2712 | 2747 | sendText(pOut,z, i, 0); |
| 2713 | 2748 | |