Fossil SCM

Corrected help_to_html() to escape less-than signs so that script tags in help text do not break the page. Removed a semantically illegal P tag from the HTML-format help.

stephan 2020-08-11 11:13 trunk
Commit 9850dd3f22db7e09388e1b9d3b964e196a8214669e02989a47c833054efa5a3d
1 file changed +10 -2
+10 -2
--- src/dispatch.c
+++ src/dispatch.c
@@ -343,17 +343,22 @@
343343
azEnd[0] = "";
344344
while( zHelp[0] ){
345345
i = 0;
346346
while( (c = zHelp[i])!=0
347347
&& c!='\n'
348
+ && c!='<'
348349
&& (c!='%' || strncmp(zHelp+i,"%fossil",7)!=0)
349350
){ i++; }
350351
if( c=='%' ){
351352
if( i ) blob_appendf(pHtml, "%#h", i, zHelp);
352353
zHelp += i + 1;
353
- i = 0;
354354
wantBR = 1;
355
+ continue;
356
+ }else if( c=='<' ){
357
+ if( i ) blob_appendf(pHtml, "%#h", i, zHelp);
358
+ blob_append(pHtml, "&amp;", 5);
359
+ zHelp += i + 1;
355360
continue;
356361
}
357362
if( i>2 && zHelp[0]=='>' && zHelp[1]==' ' ){
358363
isDT = 1;
359364
for(nIndent=1; nIndent<i && zHelp[nIndent]==' '; nIndent++){}
@@ -408,11 +413,14 @@
408413
}
409414
if( isLI ){
410415
blob_append(pHtml, "<li> ", 5);
411416
}
412417
if( wantP ){
413
- blob_append(pHtml, "<p> ", 4);
418
+ /* We historically output a <P> tag here but that is
419
+ semantically illegal (P may only contain inline elements) and
420
+ browsers were automatically relocating its contents after the
421
+ P in the DOM. */
414422
wantP = 0;
415423
}
416424
if( azEnd[iLevel]==zEndDL ){
417425
int iDD;
418426
blob_append(pHtml, "<dt> ", 5);
419427
--- src/dispatch.c
+++ src/dispatch.c
@@ -343,17 +343,22 @@
343 azEnd[0] = "";
344 while( zHelp[0] ){
345 i = 0;
346 while( (c = zHelp[i])!=0
347 && c!='\n'
 
348 && (c!='%' || strncmp(zHelp+i,"%fossil",7)!=0)
349 ){ i++; }
350 if( c=='%' ){
351 if( i ) blob_appendf(pHtml, "%#h", i, zHelp);
352 zHelp += i + 1;
353 i = 0;
354 wantBR = 1;
 
 
 
 
 
355 continue;
356 }
357 if( i>2 && zHelp[0]=='>' && zHelp[1]==' ' ){
358 isDT = 1;
359 for(nIndent=1; nIndent<i && zHelp[nIndent]==' '; nIndent++){}
@@ -408,11 +413,14 @@
408 }
409 if( isLI ){
410 blob_append(pHtml, "<li> ", 5);
411 }
412 if( wantP ){
413 blob_append(pHtml, "<p> ", 4);
 
 
 
414 wantP = 0;
415 }
416 if( azEnd[iLevel]==zEndDL ){
417 int iDD;
418 blob_append(pHtml, "<dt> ", 5);
419
--- src/dispatch.c
+++ src/dispatch.c
@@ -343,17 +343,22 @@
343 azEnd[0] = "";
344 while( zHelp[0] ){
345 i = 0;
346 while( (c = zHelp[i])!=0
347 && c!='\n'
348 && c!='<'
349 && (c!='%' || strncmp(zHelp+i,"%fossil",7)!=0)
350 ){ i++; }
351 if( c=='%' ){
352 if( i ) blob_appendf(pHtml, "%#h", i, zHelp);
353 zHelp += i + 1;
 
354 wantBR = 1;
355 continue;
356 }else if( c=='<' ){
357 if( i ) blob_appendf(pHtml, "%#h", i, zHelp);
358 blob_append(pHtml, "&amp;", 5);
359 zHelp += i + 1;
360 continue;
361 }
362 if( i>2 && zHelp[0]=='>' && zHelp[1]==' ' ){
363 isDT = 1;
364 for(nIndent=1; nIndent<i && zHelp[nIndent]==' '; nIndent++){}
@@ -408,11 +413,14 @@
413 }
414 if( isLI ){
415 blob_append(pHtml, "<li> ", 5);
416 }
417 if( wantP ){
418 /* We historically output a <P> tag here but that is
419 semantically illegal (P may only contain inline elements) and
420 browsers were automatically relocating its contents after the
421 P in the DOM. */
422 wantP = 0;
423 }
424 if( azEnd[iLevel]==zEndDL ){
425 int iDD;
426 blob_append(pHtml, "<dt> ", 5);
427

Keyboard Shortcuts

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