Fossil SCM

Ignore byte-order-marks at the beginning of wiki pages. Ticket [466e4bbdc7c90d5]

drh 2010-04-27 23:55 trunk
Commit 9d6507d25d6ab491a727ed59c1b1ddc148dbad0f
1 file changed +11 -2
+11 -2
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1390,10 +1390,19 @@
13901390
}
13911391
z += n;
13921392
}
13931393
}
13941394
1395
+/*
1396
+** Skip over the UTF-8 Byte-Order-Mark that some broken Windows
1397
+** tools add to the beginning of text files.
1398
+*/
1399
+char *skip_bom(char *z){
1400
+ static const char bom[] = { 0xEF, 0xBB, 0xBF };
1401
+ if( z && memcmp(z, bom, 3)==0 ) z += 3;
1402
+ return z;
1403
+}
13951404
13961405
/*
13971406
** Transform the text in the pIn blob. Write the results
13981407
** into the pOut blob. The pOut blob should already be
13991408
** initialized. The output is merely appended to pOut.
@@ -1421,11 +1430,11 @@
14211430
renderer.pOut = pOut;
14221431
}else{
14231432
renderer.pOut = cgi_output_blob();
14241433
}
14251434
1426
- z = blob_str(pIn);
1435
+ z = skip_bom(blob_str(pIn));
14271436
wiki_render(&renderer, z);
14281437
endAutoParagraph(&renderer);
14291438
while( renderer.nStack ){
14301439
popStack(&renderer);
14311440
}
@@ -1456,11 +1465,11 @@
14561465
*/
14571466
int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
14581467
char *z;
14591468
int i;
14601469
int iStart;
1461
- z = blob_str(pIn);
1470
+ z = skip_bom(blob_str(pIn));
14621471
for(i=0; isspace(z[i]); i++){}
14631472
if( z[i]!='<' ) return 0;
14641473
i++;
14651474
if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
14661475
iStart = i+6;
14671476
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1390,10 +1390,19 @@
1390 }
1391 z += n;
1392 }
1393 }
1394
 
 
 
 
 
 
 
 
 
1395
1396 /*
1397 ** Transform the text in the pIn blob. Write the results
1398 ** into the pOut blob. The pOut blob should already be
1399 ** initialized. The output is merely appended to pOut.
@@ -1421,11 +1430,11 @@
1421 renderer.pOut = pOut;
1422 }else{
1423 renderer.pOut = cgi_output_blob();
1424 }
1425
1426 z = blob_str(pIn);
1427 wiki_render(&renderer, z);
1428 endAutoParagraph(&renderer);
1429 while( renderer.nStack ){
1430 popStack(&renderer);
1431 }
@@ -1456,11 +1465,11 @@
1456 */
1457 int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
1458 char *z;
1459 int i;
1460 int iStart;
1461 z = blob_str(pIn);
1462 for(i=0; isspace(z[i]); i++){}
1463 if( z[i]!='<' ) return 0;
1464 i++;
1465 if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
1466 iStart = i+6;
1467
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1390,10 +1390,19 @@
1390 }
1391 z += n;
1392 }
1393 }
1394
1395 /*
1396 ** Skip over the UTF-8 Byte-Order-Mark that some broken Windows
1397 ** tools add to the beginning of text files.
1398 */
1399 char *skip_bom(char *z){
1400 static const char bom[] = { 0xEF, 0xBB, 0xBF };
1401 if( z && memcmp(z, bom, 3)==0 ) z += 3;
1402 return z;
1403 }
1404
1405 /*
1406 ** Transform the text in the pIn blob. Write the results
1407 ** into the pOut blob. The pOut blob should already be
1408 ** initialized. The output is merely appended to pOut.
@@ -1421,11 +1430,11 @@
1430 renderer.pOut = pOut;
1431 }else{
1432 renderer.pOut = cgi_output_blob();
1433 }
1434
1435 z = skip_bom(blob_str(pIn));
1436 wiki_render(&renderer, z);
1437 endAutoParagraph(&renderer);
1438 while( renderer.nStack ){
1439 popStack(&renderer);
1440 }
@@ -1456,11 +1465,11 @@
1465 */
1466 int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
1467 char *z;
1468 int i;
1469 int iStart;
1470 z = skip_bom(blob_str(pIn));
1471 for(i=0; isspace(z[i]); i++){}
1472 if( z[i]!='<' ) return 0;
1473 i++;
1474 if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
1475 iStart = i+6;
1476

Keyboard Shortcuts

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