Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -1210,7 +1210,8 @@ |
1211 | 1211 | |} |
1212 | 1212 | !! result |
1213 | 1213 | <table> |
1214 | | -<caption> caption |
| 1214 | +<caption> |
| 1215 | +caption |
1215 | 1216 | </caption><tr><td></td></tr></table> |
1216 | 1217 | |
1217 | 1218 | !! end |
— | — | @@ -1226,12 +1227,22 @@ |
1227 | 1228 | !! result |
1228 | 1229 | <table> |
1229 | 1230 | <tr> |
1230 | | -<td> 1 </td> |
1231 | | -<td> 2 |
| 1231 | +<td> |
| 1232 | +<p>1 |
| 1233 | +</p> |
| 1234 | +</td> |
| 1235 | +<td> |
| 1236 | +<p>2 |
| 1237 | +</p> |
1232 | 1238 | </td></tr> |
1233 | 1239 | <tr> |
1234 | | -<td> 3 </td> |
1235 | | -<td> 4 |
| 1240 | +<td> |
| 1241 | +<p>3 |
| 1242 | +</p> |
| 1243 | +</td> |
| 1244 | +<td> |
| 1245 | +<p>4 |
| 1246 | +</p> |
1236 | 1247 | </td></tr></table> |
1237 | 1248 | |
1238 | 1249 | !! end |
— | — | @@ -1261,48 +1272,110 @@ |
1262 | 1273 | |} |
1263 | 1274 | !! result |
1264 | 1275 | <table border="1" cellpadding="2"> |
1265 | | -<caption>Multiplication table |
| 1276 | +<caption> |
| 1277 | +Multiplication table |
1266 | 1278 | </caption> |
1267 | 1279 | <tr> |
1268 | | -<th> × </th> |
1269 | | -<th> 1 </th> |
1270 | | -<th> 2 </th> |
1271 | | -<th> 3 |
| 1280 | +<th> |
| 1281 | +<p>× |
| 1282 | +</p> |
| 1283 | +</th> |
| 1284 | +<th> |
| 1285 | +<p>1 |
| 1286 | +</p> |
| 1287 | +</th> |
| 1288 | +<th> |
| 1289 | +<p>2 |
| 1290 | +</p> |
| 1291 | +</th> |
| 1292 | +<th> |
| 1293 | +<p>3 |
| 1294 | +</p> |
1272 | 1295 | </th></tr> |
1273 | 1296 | <tr> |
1274 | | -<th> 1 |
| 1297 | +<th> |
| 1298 | +<p>1 |
| 1299 | +</p> |
1275 | 1300 | </th> |
1276 | | -<td> 1 </td> |
1277 | | -<td> 2 </td> |
1278 | | -<td> 3 |
| 1301 | +<td> |
| 1302 | +<p>1 |
| 1303 | +</p> |
| 1304 | +</td> |
| 1305 | +<td> |
| 1306 | +<p>2 |
| 1307 | +</p> |
| 1308 | +</td> |
| 1309 | +<td> |
| 1310 | +<p>3 |
| 1311 | +</p> |
1279 | 1312 | </td></tr> |
1280 | 1313 | <tr> |
1281 | | -<th> 2 |
| 1314 | +<th> |
| 1315 | +<p>2 |
| 1316 | +</p> |
1282 | 1317 | </th> |
1283 | | -<td> 2 </td> |
1284 | | -<td> 4 </td> |
1285 | | -<td> 6 |
| 1318 | +<td> |
| 1319 | +<p>2 |
| 1320 | +</p> |
| 1321 | +</td> |
| 1322 | +<td> |
| 1323 | +<p>4 |
| 1324 | +</p> |
| 1325 | +</td> |
| 1326 | +<td> |
| 1327 | +<p>6 |
| 1328 | +</p> |
1286 | 1329 | </td></tr> |
1287 | 1330 | <tr> |
1288 | | -<th> 3 |
| 1331 | +<th> |
| 1332 | +<p>3 |
| 1333 | +</p> |
1289 | 1334 | </th> |
1290 | | -<td> 3 </td> |
1291 | | -<td> 6 </td> |
1292 | | -<td> 9 |
| 1335 | +<td> |
| 1336 | +<p>3 |
| 1337 | +</p> |
| 1338 | +</td> |
| 1339 | +<td> |
| 1340 | +<p>6 |
| 1341 | +</p> |
| 1342 | +</td> |
| 1343 | +<td> |
| 1344 | +<p>9 |
| 1345 | +</p> |
1293 | 1346 | </td></tr> |
1294 | 1347 | <tr> |
1295 | | -<th> 4 |
| 1348 | +<th> |
| 1349 | +<p>4 |
| 1350 | +</p> |
1296 | 1351 | </th> |
1297 | | -<td> 4 </td> |
1298 | | -<td> 8 </td> |
1299 | | -<td> 12 |
| 1352 | +<td> |
| 1353 | +<p>4 |
| 1354 | +</p> |
| 1355 | +</td> |
| 1356 | +<td> |
| 1357 | +<p>8 |
| 1358 | +</p> |
| 1359 | +</td> |
| 1360 | +<td> |
| 1361 | +<p>12 |
| 1362 | +</p> |
1300 | 1363 | </td></tr> |
1301 | 1364 | <tr> |
1302 | | -<th> 5 |
| 1365 | +<th> |
| 1366 | +<p>5 |
| 1367 | +</p> |
1303 | 1368 | </th> |
1304 | | -<td> 5 </td> |
1305 | | -<td> 10 </td> |
1306 | | -<td> 15 |
| 1369 | +<td> |
| 1370 | +<p>5 |
| 1371 | +</p> |
| 1372 | +</td> |
| 1373 | +<td> |
| 1374 | +<p>10 |
| 1375 | +</p> |
| 1376 | +</td> |
| 1377 | +<td> |
| 1378 | +<p>15 |
| 1379 | +</p> |
1307 | 1380 | </td></tr></table> |
1308 | 1381 | |
1309 | 1382 | !! end |
— | — | @@ -1321,16 +1394,26 @@ |
1322 | 1395 | !! result |
1323 | 1396 | <table align="right" border="1"> |
1324 | 1397 | <tr> |
1325 | | -<td> Cell 1, row 1 |
| 1398 | +<td> |
| 1399 | +<p>Cell 1, row 1 |
| 1400 | +</p> |
1326 | 1401 | </td> |
1327 | | -<td rowspan="2"> Cell 2, row 1 (and 2) |
| 1402 | +<td rowspan="2"> |
| 1403 | +<p>Cell 2, row 1 (and 2) |
| 1404 | +</p> |
1328 | 1405 | </td> |
1329 | | -<td> Cell 3, row 1 |
| 1406 | +<td> |
| 1407 | +<p>Cell 3, row 1 |
| 1408 | +</p> |
1330 | 1409 | </td></tr> |
1331 | 1410 | <tr> |
1332 | | -<td> Cell 1, row 2 |
| 1411 | +<td> |
| 1412 | +<p>Cell 1, row 2 |
| 1413 | +</p> |
1333 | 1414 | </td> |
1334 | | -<td> Cell 3, row 2 |
| 1415 | +<td> |
| 1416 | +<p>Cell 3, row 2 |
| 1417 | +</p> |
1335 | 1418 | </td></tr></table> |
1336 | 1419 | |
1337 | 1420 | !! end |
— | — | @@ -1351,18 +1434,26 @@ |
1352 | 1435 | !! result |
1353 | 1436 | <table border="1"> |
1354 | 1437 | <tr> |
1355 | | -<td> α |
| 1438 | +<td> |
| 1439 | +<p>α |
| 1440 | +</p> |
1356 | 1441 | </td> |
1357 | 1442 | <td> |
1358 | 1443 | <table bgcolor="#ABCDEF" border="2"> |
1359 | 1444 | <tr> |
1360 | | -<td>nested |
| 1445 | +<td> |
| 1446 | +<p>nested |
| 1447 | +</p> |
1361 | 1448 | </td></tr> |
1362 | 1449 | <tr> |
1363 | | -<td>table |
| 1450 | +<td> |
| 1451 | +<p>table |
| 1452 | +</p> |
1364 | 1453 | </td></tr></table> |
1365 | 1454 | </td> |
1366 | | -<td>the original table again |
| 1455 | +<td> |
| 1456 | +<p>the original table again |
| 1457 | +</p> |
1367 | 1458 | </td></tr></table> |
1368 | 1459 | |
1369 | 1460 | !! end |
— | — | @@ -1376,7 +1467,9 @@ |
1377 | 1468 | !! result |
1378 | 1469 | <table> |
1379 | 1470 | <tr> |
1380 | | -<td>broken |
| 1471 | +<td> |
| 1472 | +<p>broken |
| 1473 | +</p> |
1381 | 1474 | </td></tr></table> |
1382 | 1475 | |
1383 | 1476 | !! end |
— | — | @@ -1390,9 +1483,14 @@ |
1391 | 1484 | !! result |
1392 | 1485 | <table> |
1393 | 1486 | <tr> |
1394 | | -<td>[<a href="ftp://%7Cx" class="external free" rel="nofollow">ftp://%7Cx</a></td> |
1395 | | -<td>]" onmouseover="alert(document.cookie)">test |
| 1487 | +<td> |
| 1488 | +<p>[<a href="ftp://%7Cx" class="external free" rel="nofollow">ftp://%7Cx</a> |
| 1489 | +</p> |
1396 | 1490 | </td> |
| 1491 | +<td> |
| 1492 | +<p>]" onmouseover="alert(document.cookie)">test |
| 1493 | +</p> |
| 1494 | +</td> |
1397 | 1495 | </tr> |
1398 | 1496 | </table> |
1399 | 1497 | |
— | — | @@ -2571,7 +2669,9 @@ |
2572 | 2670 | !! result |
2573 | 2671 | <table> |
2574 | 2672 | <tr> |
2575 | | -<td>[[{{{1}}}|{{{2}}}]] |
| 2673 | +<td> |
| 2674 | +<p>[[{{{1}}}|{{{2}}}]] |
| 2675 | +</p> |
2576 | 2676 | </td></tr></table> |
2577 | 2677 | |
2578 | 2678 | !! end |
— | — | @@ -2681,12 +2781,22 @@ |
2682 | 2782 | </p> |
2683 | 2783 | <table> |
2684 | 2784 | <tr> |
2685 | | -<td> 1 </td> |
2686 | | -<td> 2 |
| 2785 | +<td> |
| 2786 | +<p>1 |
| 2787 | +</p> |
| 2788 | +</td> |
| 2789 | +<td> |
| 2790 | +<p>2 |
| 2791 | +</p> |
2687 | 2792 | </td></tr> |
2688 | 2793 | <tr> |
2689 | | -<td> 3 </td> |
2690 | | -<td> 4 |
| 2794 | +<td> |
| 2795 | +<p>3 |
| 2796 | +</p> |
| 2797 | +</td> |
| 2798 | +<td> |
| 2799 | +<p>4 |
| 2800 | +</p> |
2691 | 2801 | </td></tr></table> |
2692 | 2802 | |
2693 | 2803 | !! end |
— | — | @@ -2701,12 +2811,22 @@ |
2702 | 2812 | </p> |
2703 | 2813 | <table> |
2704 | 2814 | <tr> |
2705 | | -<td> 1 </td> |
2706 | | -<td> 2 |
| 2815 | +<td> |
| 2816 | +<p>1 |
| 2817 | +</p> |
| 2818 | +</td> |
| 2819 | +<td> |
| 2820 | +<p>2 |
| 2821 | +</p> |
2707 | 2822 | </td></tr> |
2708 | 2823 | <tr> |
2709 | | -<td> 3 </td> |
2710 | | -<td> 4 |
| 2824 | +<td> |
| 2825 | +<p>3 |
| 2826 | +</p> |
| 2827 | +</td> |
| 2828 | +<td> |
| 2829 | +<p>4 |
| 2830 | +</p> |
2711 | 2831 | </td></tr></table> |
2712 | 2832 | |
2713 | 2833 | !! end |
— | — | @@ -4287,7 +4407,9 @@ |
4288 | 4408 | !! result |
4289 | 4409 | <table> |
4290 | 4410 | <tr> |
4291 | | -<th class="awesome"> status |
| 4411 | +<th class="awesome"> |
| 4412 | +<p>status |
| 4413 | +</p> |
4292 | 4414 | </th></tr></table> |
4293 | 4415 | |
4294 | 4416 | !!end |
— | — | @@ -4741,7 +4863,9 @@ |
4742 | 4864 | !! result |
4743 | 4865 | <table> |
4744 | 4866 | <tr> |
4745 | | -<th style="color:blue"> status |
| 4867 | +<th style="color:blue"> |
| 4868 | +<p>status |
| 4869 | +</p> |
4746 | 4870 | </th></tr></table> |
4747 | 4871 | |
4748 | 4872 | !!end |
— | — | @@ -4755,7 +4879,9 @@ |
4756 | 4880 | !! result |
4757 | 4881 | <table> |
4758 | 4882 | <tr> |
4759 | | -<th style="/* insecure input */"> status |
| 4883 | +<th style="/* insecure input */"> |
| 4884 | +<p>status |
| 4885 | +</p> |
4760 | 4886 | </th></tr></table> |
4761 | 4887 | |
4762 | 4888 | !! end |
— | — | @@ -5424,10 +5550,15 @@ |
5425 | 5551 | !! result |
5426 | 5552 | <table> |
5427 | 5553 | <tr> |
5428 | | -<th>https://</th> |
5429 | | -<th></th> |
5430 | | -<th></th> |
5431 | 5554 | <th> |
| 5555 | +<p>https:// |
| 5556 | +</p> |
| 5557 | +</th> |
| 5558 | +<th> |
| 5559 | +</th> |
| 5560 | +<th> |
| 5561 | +</th> |
| 5562 | +<th> |
5432 | 5563 | </td> |
5433 | 5564 | </tr> |
5434 | 5565 | </table> |
— | — | @@ -5443,7 +5574,9 @@ |
5444 | 5575 | !! result |
5445 | 5576 | <table> |
5446 | 5577 | <tr> |
5447 | | -<th> <a href="irc://{{ftp://a" class="external free" rel="nofollow">irc://{{ftp://a</a>" onmouseover="alert('hello world');" |
| 5578 | +<th> |
| 5579 | +<p><a href="irc://{{ftp://a" class="external free" rel="nofollow">irc://{{ftp://a</a>" onmouseover="alert('hello world');" |
| 5580 | +</p> |
5448 | 5581 | </th> |
5449 | 5582 | <td> |
5450 | 5583 | </td> |
— | — | @@ -5489,7 +5622,9 @@ |
5490 | 5623 | |
5491 | 5624 | MOVE YOUR MOUSE CURSOR OVER THIS TEXT |
5492 | 5625 | <tr> |
5493 | | -<td></u> |
| 5626 | +<td> |
| 5627 | +<p></u> |
| 5628 | +</p> |
5494 | 5629 | </td> |
5495 | 5630 | </tr> |
5496 | 5631 | </table> |
— | — | @@ -7604,18 +7739,17 @@ |
7605 | 7740 | !!endarticle |
7606 | 7741 | |
7607 | 7742 | !! test |
7608 | | -Bug 529: Uncovered bullet |
| 7743 | +Bug 529/12974: Uncovered bullet |
7609 | 7744 | !! input |
7610 | 7745 | * Foo {{bullet}} |
7611 | 7746 | !! result |
7612 | | -<ul><li> Foo |
7613 | | -</li><li> Bar |
| 7747 | +<ul><li> Foo * Bar |
7614 | 7748 | </li></ul> |
7615 | 7749 | |
7616 | 7750 | !! end |
7617 | 7751 | |
7618 | 7752 | !! test |
7619 | | -Bug 529: Uncovered table already at line-start |
| 7753 | +Bug 529/12974: Uncovered table already at line-start |
7620 | 7754 | !! input |
7621 | 7755 | x |
7622 | 7756 | |
— | — | @@ -7626,24 +7760,33 @@ |
7627 | 7761 | </p> |
7628 | 7762 | <table> |
7629 | 7763 | <tr> |
7630 | | -<td> 1 </td> |
7631 | | -<td> 2 |
| 7764 | +<td> |
| 7765 | +<p>1 |
| 7766 | +</p> |
| 7767 | +</td> |
| 7768 | +<td> |
| 7769 | +<p>2 |
| 7770 | +</p> |
7632 | 7771 | </td></tr> |
7633 | 7772 | <tr> |
7634 | | -<td> 3 </td> |
7635 | | -<td> 4 |
| 7773 | +<td> |
| 7774 | +<p>3 |
| 7775 | +</p> |
| 7776 | +</td> |
| 7777 | +<td> |
| 7778 | +<p>4 |
| 7779 | +</p> |
7636 | 7780 | </td></tr></table> |
7637 | 7781 | <p>y |
7638 | 7782 | </p> |
7639 | 7783 | !! end |
7640 | 7784 | |
7641 | 7785 | !! test |
7642 | | -Bug 529: Uncovered bullet in parser function result |
| 7786 | +Bug 529/12974: Uncovered bullet in parser function result |
7643 | 7787 | !! input |
7644 | 7788 | * Foo {{lc:{{bullet}} }} |
7645 | 7789 | !! result |
7646 | | -<ul><li> Foo |
7647 | | -</li><li> bar |
| 7790 | +<ul><li> Foo * bar |
7648 | 7791 | </li></ul> |
7649 | 7792 | |
7650 | 7793 | !! end |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -825,7 +825,22 @@ |
826 | 826 | $has_opened_tr = array(); # Did this table open a <tr> element? |
827 | 827 | $indent_level = 0; # indent level of the table |
828 | 828 | |
829 | | - foreach ( $lines as $outLine ) { |
| 829 | + # Keep pulling lines off the front of the array until they're all gone. |
| 830 | + # we want to be able to push lines back on to the front of the stream, |
| 831 | + # but StringUtils::explode() returns funky optimised Iterators which don't |
| 832 | + # support insertion. So maintain a separate buffer and draw on that first if |
| 833 | + # there's anything in it |
| 834 | + $extraLines = array(); |
| 835 | + $lines->rewind(); |
| 836 | + do { |
| 837 | + if( $extraLines ){ |
| 838 | + $outLine = array_shift( $extraLines ); |
| 839 | + } elseif( $lines->valid() ) { |
| 840 | + $outLine = $lines->current(); |
| 841 | + $lines->next(); |
| 842 | + } else { |
| 843 | + break; |
| 844 | + } |
830 | 845 | $line = trim( $outLine ); |
831 | 846 | |
832 | 847 | if ( $line === '' ) { # empty line, go to next line |
— | — | @@ -901,11 +916,10 @@ |
902 | 917 | } elseif ( $first_character === '|' || $first_character === '!' || substr( $line , 0 , 2 ) === '|+' ) { |
903 | 918 | # This might be cell elements, td, th or captions |
904 | 919 | if ( substr( $line , 0 , 2 ) === '|+' ) { |
905 | | - $first_character = '+'; |
906 | | - $line = substr( $line , 1 ); |
| 920 | + $first_character = '|+'; |
907 | 921 | } |
908 | 922 | |
909 | | - $line = substr( $line , 1 ); |
| 923 | + $line = substr( $line , strlen( $first_character ) ); |
910 | 924 | |
911 | 925 | if ( $first_character === '!' ) { |
912 | 926 | $line = str_replace( '!!' , '||' , $line ); |
— | — | @@ -916,62 +930,84 @@ |
917 | 931 | # by earlier parser steps, but should avoid splitting up eg |
918 | 932 | # attribute values containing literal "||". |
919 | 933 | $cells = StringUtils::explodeMarkup( '||' , $line ); |
| 934 | + $cell = array_shift( $cells ); |
920 | 935 | |
| 936 | + # Inject cells back into the stream to be dealt with later |
| 937 | + # TODO: really we should do the whole thing as a stream... |
| 938 | + # but that would be too much like a sensible implementation :P |
| 939 | + if( count( $cells ) ){ |
| 940 | + foreach( array_reverse( $cells ) as $extraCell ){ |
| 941 | + array_unshift( $extraLines, $first_character . $extraCell ); |
| 942 | + } |
| 943 | + } |
| 944 | + |
921 | 945 | $outLine = ''; |
922 | 946 | |
923 | | - # Loop through each table cell |
924 | | - foreach ( $cells as $cell ) { |
925 | | - $previous = ''; |
926 | | - if ( $first_character !== '+' ) { |
927 | | - $tr_after = array_pop( $tr_attributes ); |
928 | | - if ( !array_pop( $tr_history ) ) { |
929 | | - $previous = "<tr{$tr_after}>\n"; |
930 | | - } |
931 | | - array_push( $tr_history , true ); |
932 | | - array_push( $tr_attributes , '' ); |
933 | | - array_pop( $has_opened_tr ); |
934 | | - array_push( $has_opened_tr , true ); |
| 947 | + $previous = ''; |
| 948 | + if ( $first_character !== '|+' ) { |
| 949 | + $tr_after = array_pop( $tr_attributes ); |
| 950 | + if ( !array_pop( $tr_history ) ) { |
| 951 | + $previous = "<tr{$tr_after}>\n"; |
935 | 952 | } |
| 953 | + array_push( $tr_history , true ); |
| 954 | + array_push( $tr_attributes , '' ); |
| 955 | + array_pop( $has_opened_tr ); |
| 956 | + array_push( $has_opened_tr , true ); |
| 957 | + } |
936 | 958 | |
937 | | - $last_tag = array_pop( $last_tag_history ); |
| 959 | + $last_tag = array_pop( $last_tag_history ); |
938 | 960 | |
939 | | - if ( array_pop( $td_history ) ) { |
940 | | - $previous = "</{$last_tag}>\n{$previous}"; |
941 | | - } |
| 961 | + if ( array_pop( $td_history ) ) { |
| 962 | + $previous = "</{$last_tag}>\n{$previous}"; |
| 963 | + } |
942 | 964 | |
943 | | - if ( $first_character === '|' ) { |
944 | | - $last_tag = 'td'; |
945 | | - } elseif ( $first_character === '!' ) { |
946 | | - $last_tag = 'th'; |
947 | | - } elseif ( $first_character === '+' ) { |
948 | | - $last_tag = 'caption'; |
949 | | - } else { |
950 | | - $last_tag = ''; |
951 | | - } |
| 965 | + if ( $first_character === '|' ) { |
| 966 | + $last_tag = 'td'; |
| 967 | + } elseif ( $first_character === '!' ) { |
| 968 | + $last_tag = 'th'; |
| 969 | + } elseif ( $first_character === '|+' ) { |
| 970 | + $last_tag = 'caption'; |
| 971 | + } else { |
| 972 | + $last_tag = ''; |
| 973 | + } |
952 | 974 | |
953 | | - array_push( $last_tag_history , $last_tag ); |
| 975 | + array_push( $last_tag_history , $last_tag ); |
954 | 976 | |
955 | | - # A cell could contain both parameters and data |
956 | | - $cell_data = explode( '|' , $cell , 2 ); |
| 977 | + # A cell could contain both parameters and data... but the pipe could |
| 978 | + # also be the start of a nested table, or a raw pipe inside an invalid |
| 979 | + # link (bug 553). |
| 980 | + $cell_data = preg_split( '/(?<!\{)\|/', $cell, 2 ); |
957 | 981 | |
958 | | - # Bug 553: Note that a '|' inside an invalid link should not |
959 | | - # be mistaken as delimiting cell parameters |
960 | | - if ( strpos( $cell_data[0], '[[' ) !== false ) { |
961 | | - $cell = "{$previous}<{$last_tag}>{$cell}"; |
962 | | - } elseif ( count( $cell_data ) == 1 ) { |
963 | | - $cell = "{$previous}<{$last_tag}>{$cell_data[0]}"; |
964 | | - } else { |
965 | | - $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); |
966 | | - $attributes = Sanitizer::fixTagAttributes( $attributes , $last_tag ); |
967 | | - $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"; |
968 | | - } |
| 982 | + # Bug 553: a '|' inside an invalid link should not |
| 983 | + # be mistaken as delimiting cell parameters |
| 984 | + if ( strpos( $cell_data[0], '[[' ) !== false ) { |
| 985 | + $data = $cell; |
| 986 | + $cell = "{$previous}<{$last_tag}>"; |
| 987 | + } elseif ( count( $cell_data ) == 1 ) { |
| 988 | + $cell = "{$previous}<{$last_tag}>"; |
| 989 | + $data = $cell_data[0]; |
| 990 | + } else { |
| 991 | + $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); |
| 992 | + $attributes = Sanitizer::fixTagAttributes( $attributes , $last_tag ); |
| 993 | + $cell = "{$previous}<{$last_tag}{$attributes}>"; |
| 994 | + $data = $cell_data[1]; |
| 995 | + } |
969 | 996 | |
970 | | - $outLine .= $cell; |
971 | | - array_push( $td_history , true ); |
| 997 | + # Bug 529: the start of a table cell should be a linestart context for |
| 998 | + # processing other block markup, including nested tables. The original |
| 999 | + # implementation of this was to add a newline before every brace construct, |
| 1000 | + # which broke all manner of other things. Instead, push the contents |
| 1001 | + # of the cell back into the stream and come back to it later. But don't |
| 1002 | + # do that if the first line is empty, or you may get extra whitespace |
| 1003 | + if( $data ){ |
| 1004 | + array_unshift( $extraLines, trim( $data ) ); |
972 | 1005 | } |
| 1006 | + |
| 1007 | + $outLine .= $cell; |
| 1008 | + array_push( $td_history , true ); |
973 | 1009 | } |
974 | 1010 | $out .= $outLine . "\n"; |
975 | | - } |
| 1011 | + } while( $lines->valid() || count( $extraLines ) ); |
976 | 1012 | |
977 | 1013 | # Closing open td, tr && table |
978 | 1014 | while ( count( $td_history ) > 0 ) { |
— | — | @@ -2235,6 +2271,7 @@ |
2236 | 2272 | '/(?:<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'. |
2237 | 2273 | '<td|<th|<\\/?div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/?center)/iS', $t ); |
2238 | 2274 | if ( $openmatch or $closematch ) { |
| 2275 | + |
2239 | 2276 | $paragraphStack = false; |
2240 | 2277 | # TODO bug 5718: paragraph closed |
2241 | 2278 | $output .= $this->closeParagraph(); |
— | — | @@ -3225,11 +3262,11 @@ |
3226 | 3263 | $text = wfEscapeWikiText( $text ); |
3227 | 3264 | } elseif ( is_string( $text ) |
3228 | 3265 | && !$piece['lineStart'] |
3229 | | - && preg_match( '/^(?:{\\||:|;|#|\*)/', $text ) ) |
| 3266 | + && preg_match( '/^{\\|/', $text ) ) |
3230 | 3267 | { |
3231 | | - # Bug 529: if the template begins with a table or block-level |
3232 | | - # element, it should be treated as beginning a new line. |
3233 | | - # This behaviour is somewhat controversial. |
| 3268 | + # Bug 529: if the template begins with a table, it should be treated as |
| 3269 | + # beginning a new line. This previously handled other block-level elements |
| 3270 | + # such as #, :, etc, but these have many false-positives (bug 12974). |
3234 | 3271 | $text = "\n" . $text; |
3235 | 3272 | } |
3236 | 3273 | |
— | — | @@ -3288,7 +3325,7 @@ |
3289 | 3326 | |
3290 | 3327 | if ( !$title->equals( $cacheTitle ) ) { |
3291 | 3328 | $this->mTplRedirCache[$cacheTitle->getPrefixedDBkey()] = |
3292 | | - array( $title->getNamespace(), $cdb = $title->getDBkey() ); |
| 3329 | + array( $title->getNamespace(), $title->getDBkey() ); |
3293 | 3330 | } |
3294 | 3331 | |
3295 | 3332 | return array( $dom, $title ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -87,6 +87,11 @@ |
88 | 88 | members. |
89 | 89 | * (bug 2585) Image pages should send 404 if no image, no shared image and no |
90 | 90 | description page. |
| 91 | +* (bug 12974) The behaviour of wikitable and template parsing was altered. Previously, |
| 92 | + all templates were treated as being at the start of a block context for the purposes |
| 93 | + of evaluating wikitext elements like #, :, *, and tables (bug 529). Now this |
| 94 | + behaviour is only applied to wikitable-start {|, but the first line of a wikitable |
| 95 | + cell is now treated as a linestart. |
91 | 96 | |
92 | 97 | === API changes in 1.18 === |
93 | 98 | * (bug 26339) Throw warning when truncating an overlarge API result |