Fossil SCM

Fix html escaping of TH1 variables. Escaping should be determined by $<a> or $a form, but instead it was based on the relationship between the length of the variable name and the length of the value.

steveb 2011-11-04 18:57 steveb-fixes
Commit d81e217651dc68a8f034f396cb6ddb78dfa35ba5
1 file changed +5 -3
+5 -3
--- src/th_main.c
+++ src/th_main.c
@@ -482,25 +482,27 @@
482482
Th_FossilInit();
483483
while( z[i] ){
484484
if( z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){
485485
const char *zVar;
486486
int nVar;
487
+ int encode = 1;
487488
sendText(z, i, 0);
488489
if( z[i+1]=='<' ){
489
- /* Variables of the form $<aaa> */
490
+ /* Variables of the form $<aaa> are html escaped */
490491
zVar = &z[i+2];
491492
nVar = n-2;
492493
}else{
493
- /* Variables of the form $aaa */
494
+ /* Variables of the form $aaa are output raw */
494495
zVar = &z[i+1];
495496
nVar = n;
497
+ encode = 0;
496498
}
497499
rc = Th_GetVar(g.interp, (char*)zVar, nVar);
498500
z += i+1+n;
499501
i = 0;
500502
zResult = (char*)Th_GetResult(g.interp, &n);
501
- sendText((char*)zResult, n, n>nVar);
503
+ sendText((char*)zResult, n, encode);
502504
}else if( z[i]=='<' && isBeginScriptTag(&z[i]) ){
503505
sendText(z, i, 0);
504506
z += i+5;
505507
for(i=0; z[i] && (z[i]!='<' || !isEndScriptTag(&z[i])); i++){}
506508
rc = Th_Eval(g.interp, 0, (const char*)z, i);
507509
--- src/th_main.c
+++ src/th_main.c
@@ -482,25 +482,27 @@
482 Th_FossilInit();
483 while( z[i] ){
484 if( z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){
485 const char *zVar;
486 int nVar;
 
487 sendText(z, i, 0);
488 if( z[i+1]=='<' ){
489 /* Variables of the form $<aaa> */
490 zVar = &z[i+2];
491 nVar = n-2;
492 }else{
493 /* Variables of the form $aaa */
494 zVar = &z[i+1];
495 nVar = n;
 
496 }
497 rc = Th_GetVar(g.interp, (char*)zVar, nVar);
498 z += i+1+n;
499 i = 0;
500 zResult = (char*)Th_GetResult(g.interp, &n);
501 sendText((char*)zResult, n, n>nVar);
502 }else if( z[i]=='<' && isBeginScriptTag(&z[i]) ){
503 sendText(z, i, 0);
504 z += i+5;
505 for(i=0; z[i] && (z[i]!='<' || !isEndScriptTag(&z[i])); i++){}
506 rc = Th_Eval(g.interp, 0, (const char*)z, i);
507
--- src/th_main.c
+++ src/th_main.c
@@ -482,25 +482,27 @@
482 Th_FossilInit();
483 while( z[i] ){
484 if( z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){
485 const char *zVar;
486 int nVar;
487 int encode = 1;
488 sendText(z, i, 0);
489 if( z[i+1]=='<' ){
490 /* Variables of the form $<aaa> are html escaped */
491 zVar = &z[i+2];
492 nVar = n-2;
493 }else{
494 /* Variables of the form $aaa are output raw */
495 zVar = &z[i+1];
496 nVar = n;
497 encode = 0;
498 }
499 rc = Th_GetVar(g.interp, (char*)zVar, nVar);
500 z += i+1+n;
501 i = 0;
502 zResult = (char*)Th_GetResult(g.interp, &n);
503 sendText((char*)zResult, n, encode);
504 }else if( z[i]=='<' && isBeginScriptTag(&z[i]) ){
505 sendText(z, i, 0);
506 z += i+5;
507 for(i=0; z[i] && (z[i]!='<' || !isEndScriptTag(&z[i])); i++){}
508 rc = Th_Eval(g.interp, 0, (const char*)z, i);
509

Keyboard Shortcuts

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