Fossil SCM
Ignore byte-order-marks at the beginning of wiki pages. Ticket [466e4bbdc7c90d5]
Commit
9d6507d25d6ab491a727ed59c1b1ddc148dbad0f
Parent
5568603e5700e69…
1 file changed
+11
-2
+11
-2
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1390,10 +1390,19 @@ | ||
| 1390 | 1390 | } |
| 1391 | 1391 | z += n; |
| 1392 | 1392 | } |
| 1393 | 1393 | } |
| 1394 | 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 | +} | |
| 1395 | 1404 | |
| 1396 | 1405 | /* |
| 1397 | 1406 | ** Transform the text in the pIn blob. Write the results |
| 1398 | 1407 | ** into the pOut blob. The pOut blob should already be |
| 1399 | 1408 | ** initialized. The output is merely appended to pOut. |
| @@ -1421,11 +1430,11 @@ | ||
| 1421 | 1430 | renderer.pOut = pOut; |
| 1422 | 1431 | }else{ |
| 1423 | 1432 | renderer.pOut = cgi_output_blob(); |
| 1424 | 1433 | } |
| 1425 | 1434 | |
| 1426 | - z = blob_str(pIn); | |
| 1435 | + z = skip_bom(blob_str(pIn)); | |
| 1427 | 1436 | wiki_render(&renderer, z); |
| 1428 | 1437 | endAutoParagraph(&renderer); |
| 1429 | 1438 | while( renderer.nStack ){ |
| 1430 | 1439 | popStack(&renderer); |
| 1431 | 1440 | } |
| @@ -1456,11 +1465,11 @@ | ||
| 1456 | 1465 | */ |
| 1457 | 1466 | int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){ |
| 1458 | 1467 | char *z; |
| 1459 | 1468 | int i; |
| 1460 | 1469 | int iStart; |
| 1461 | - z = blob_str(pIn); | |
| 1470 | + z = skip_bom(blob_str(pIn)); | |
| 1462 | 1471 | for(i=0; isspace(z[i]); i++){} |
| 1463 | 1472 | if( z[i]!='<' ) return 0; |
| 1464 | 1473 | i++; |
| 1465 | 1474 | if( strncmp(&z[i],"title>", 6)!=0 ) return 0; |
| 1466 | 1475 | iStart = i+6; |
| 1467 | 1476 |
| --- 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 |