Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -5420,30 +5420,6 @@ |
5421 | 5421 | !! end |
5422 | 5422 | |
5423 | 5423 | !! test |
5424 | | -Sanitizer: Validating that <meta> and <link> work, but only for Microdata |
5425 | | -!! input |
5426 | | -<div itemscope> |
5427 | | - <meta itemprop="hello" content="world"> |
5428 | | - <meta http-equiv="refresh" content="5"> |
5429 | | - <meta itemprop="hello" http-equiv="refresh" content="5"> |
5430 | | - <link itemprop="hello" href="{{SERVER}}"> |
5431 | | - <link rel="stylesheet" href="{{SERVER}}"> |
5432 | | - <link rel="stylesheet" itemprop="hello" href="{{SERVER}}"> |
5433 | | -</div> |
5434 | | -!! result |
5435 | | -<div itemscope="itemscope"> |
5436 | | -<p> <meta itemprop="hello" content="world" /> |
5437 | | - <meta http-equiv="refresh" content="5"> |
5438 | | - <meta itemprop="hello" content="5" /> |
5439 | | -</p> |
5440 | | - <link itemprop="hello" href="http://Britney-Spears" /> |
5441 | | - <link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://Britney-Spears">http://Britney-Spears</a>"> |
5442 | | - <link itemprop="hello" href="http://Britney-Spears" /> |
5443 | | -</div> |
5444 | | - |
5445 | | -!! end |
5446 | | - |
5447 | | -!! test |
5448 | 5424 | Language converter: output gets cut off unexpectedly (bug 5757) |
5449 | 5425 | !! options |
5450 | 5426 | language=zh |
Index: trunk/phase3/includes/parser/Tidy.php |
— | — | @@ -41,15 +41,9 @@ |
42 | 42 | dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ); |
43 | 43 | $this->mMarkerIndex = 0; |
44 | 44 | |
45 | | - // Replace <mw:editsection> elements with placeholders |
46 | 45 | $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, |
47 | 46 | array( &$this, 'replaceEditSectionLinksCallback' ), $text ); |
48 | 47 | |
49 | | - // Modify inline Microdata <link> and <meta> elements so they say <html-link> and <html-meta> so |
50 | | - // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config |
51 | | - $wrappedtext = preg_replace( '!<(link|meta)([^>]*?)(/{0,1}>)!', '<html-$1$2$3', $wrappedtext ); |
52 | | - |
53 | | - // Wrap the whole thing in a doctype and body for Tidy. |
54 | 48 | $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'. |
55 | 49 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'. |
56 | 50 | '<head><title>test</title></head><body>'.$wrappedtext.'</body></html>'; |
— | — | @@ -74,13 +68,7 @@ |
75 | 69 | * @return string |
76 | 70 | */ |
77 | 71 | public function postprocess( $text ) { |
78 | | - // Revert <html-{link,meta}> back to <{link,meta}> |
79 | | - $text = preg_replace( '!<html-(link|meta)([^>]*?)(/{0,1}>)!', '<$1$2$3', $text ); |
80 | | - |
81 | | - // Restore the contents of placeholder tokens |
82 | | - $text = $this->mTokens->replace( $text ); |
83 | | - |
84 | | - return $text; |
| 72 | + return $this->mTokens->replace( $text ); |
85 | 73 | } |
86 | 74 | |
87 | 75 | } |
Index: trunk/phase3/includes/Sanitizer.php |
— | — | @@ -364,17 +364,14 @@ |
365 | 365 | * @return string |
366 | 366 | */ |
367 | 367 | static function removeHTMLtags( $text, $processCallback = null, $args = array(), $extratags = array(), $removetags = array() ) { |
368 | | - global $wgUseTidy, $wgHtml5, $wgAllowMicrodataAttributes, $wgAllowImageTag; |
| 368 | + global $wgUseTidy; |
369 | 369 | |
370 | 370 | static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags, |
371 | 371 | $htmllist, $listtags, $htmlsingleallowed, $htmlelementsStatic, $staticInitialised; |
372 | 372 | |
373 | 373 | wfProfileIn( __METHOD__ ); |
374 | 374 | |
375 | | - // Base our staticInitialised variable off of the global config state so that if the globals |
376 | | - // are changed (like in the secrewed up test system) we will re-initialise the settings. |
377 | | - $globalContext = implode( '-', compact( 'wgHtml5', 'wgAllowMicrodataAttributes', 'wgAllowImageTag' ) ); |
378 | | - if ( !$staticInitialised || $staticInitialised != $globalContext ) { |
| 375 | + if ( !$staticInitialised ) { |
379 | 376 | |
380 | 377 | $htmlpairsStatic = array( # Tags that must be closed |
381 | 378 | 'b', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1', |
— | — | @@ -384,19 +381,12 @@ |
385 | 382 | 'ruby', 'rt' , 'rb' , 'rp', 'p', 'span', 'abbr', 'dfn', |
386 | 383 | 'kbd', 'samp' |
387 | 384 | ); |
388 | | - if ( $wgHtml5 ) { |
389 | | - $htmlpairsStatic = array_merge( $htmlpairsStatic, array( 'data', 'time' ) ); |
390 | | - } |
391 | 385 | $htmlsingle = array( |
392 | 386 | 'br', 'hr', 'li', 'dt', 'dd' |
393 | 387 | ); |
394 | 388 | $htmlsingleonly = array( # Elements that cannot have close tags |
395 | 389 | 'br', 'hr' |
396 | 390 | ); |
397 | | - if ( $wgHtml5 && $wgAllowMicrodataAttributes ) { |
398 | | - $htmlsingle[] = $htmlsingleonly[] = 'meta'; |
399 | | - $htmlsingle[] = $htmlsingleonly[] = 'link'; |
400 | | - } |
401 | 391 | $htmlnest = array( # Tags that can be nested--?? |
402 | 392 | 'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul', |
403 | 393 | 'dl', 'font', 'big', 'small', 'sub', 'sup', 'span' |
— | — | @@ -411,6 +401,7 @@ |
412 | 402 | 'li', |
413 | 403 | ); |
414 | 404 | |
| 405 | + global $wgAllowImageTag; |
415 | 406 | if ( $wgAllowImageTag ) { |
416 | 407 | $htmlsingle[] = 'img'; |
417 | 408 | $htmlsingleonly[] = 'img'; |
— | — | @@ -425,7 +416,7 @@ |
426 | 417 | foreach ( $vars as $var ) { |
427 | 418 | $$var = array_flip( $$var ); |
428 | 419 | } |
429 | | - $staticInitialised = $globalContext; |
| 420 | + $staticInitialised = true; |
430 | 421 | } |
431 | 422 | # Populate $htmlpairs and $htmlelements with the $extratags and $removetags arrays |
432 | 423 | $extratags = array_flip( $extratags ); |
— | — | @@ -537,10 +528,6 @@ |
538 | 529 | call_user_func_array( $processCallback, array( &$params, $args ) ); |
539 | 530 | } |
540 | 531 | |
541 | | - if ( !Sanitizer::validateTag( $params, $t ) ) { |
542 | | - $badtag = true; |
543 | | - } |
544 | | - |
545 | 532 | # Strip non-approved attributes from the tag |
546 | 533 | $newparams = Sanitizer::fixTagAttributes( $params, $t ); |
547 | 534 | } |
— | — | @@ -564,24 +551,16 @@ |
565 | 552 | preg_match( '/^(\\/?)(\\w+)([^>]*?)(\\/{0,1}>)([^<]*)$/', |
566 | 553 | $x, $regs ); |
567 | 554 | @list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; |
568 | | - $badtag = false; |
569 | 555 | if ( isset( $htmlelements[$t = strtolower( $t )] ) ) { |
570 | 556 | if( is_callable( $processCallback ) ) { |
571 | 557 | call_user_func_array( $processCallback, array( &$params, $args ) ); |
572 | 558 | } |
573 | | - |
574 | | - if ( !Sanitizer::validateTag( $params, $t ) ) { |
575 | | - $badtag = true; |
576 | | - } |
577 | | - |
578 | 559 | $newparams = Sanitizer::fixTagAttributes( $params, $t ); |
579 | | - if ( !$badtag ) { |
580 | | - $rest = str_replace( '>', '>', $rest ); |
581 | | - $text .= "<$slash$t$newparams$brace$rest"; |
582 | | - continue; |
583 | | - } |
| 560 | + $rest = str_replace( '>', '>', $rest ); |
| 561 | + $text .= "<$slash$t$newparams$brace$rest"; |
| 562 | + } else { |
| 563 | + $text .= '<' . str_replace( '>', '>', $x); |
584 | 564 | } |
585 | | - $text .= '<' . str_replace( '>', '>', $x); |
586 | 565 | } |
587 | 566 | } |
588 | 567 | wfProfileOut( __METHOD__ ); |
— | — | @@ -730,37 +709,6 @@ |
731 | 710 | } |
732 | 711 | |
733 | 712 | /** |
734 | | - * Takes attribute names and values for a tag and the tah name and |
735 | | - * validates that the tag is allowed to be present. |
736 | | - * This DOES NOT validate the attributes, nor does it validate the |
737 | | - * tags themselves. This method only handles the special circumstances |
738 | | - * where we may want to allow a tag within content but ONLY when it has |
739 | | - * specific attributes set. |
740 | | - * |
741 | | - * @param $ |
742 | | - */ |
743 | | - static function validateTag( $params, $element ) { |
744 | | - $params = Sanitizer::decodeTagAttributes( $params ); |
745 | | - |
746 | | - if ( $element == 'meta' || $element == 'link' ) { |
747 | | - if ( !isset( $params['itemprop'] ) ) { |
748 | | - // <meta> and <link> must have an itemprop="" otherwise they are not valid or safe in content |
749 | | - return false; |
750 | | - } |
751 | | - if ( $element == 'meta' && !isset( $params['content'] ) ) { |
752 | | - // <meta> must have a content="" for the itemprop |
753 | | - return false; |
754 | | - } |
755 | | - if ( $element == 'link' && !isset( $params['href'] ) ) { |
756 | | - // <link> must have an associated href="" |
757 | | - return false; |
758 | | - } |
759 | | - } |
760 | | - |
761 | | - return true; |
762 | | - } |
763 | | - |
764 | | - /** |
765 | 713 | * Take an array of attribute names and values and normalize or discard |
766 | 714 | * illegal values for the given element type. |
767 | 715 | * |
— | — | @@ -861,7 +809,7 @@ |
862 | 810 | unset( $out['itemid'] ); |
863 | 811 | unset( $out['itemref'] ); |
864 | 812 | } |
865 | | - # TODO: Strip itemprop if we aren't descendants of an itemscope or pointed to by an itemref. |
| 813 | + # TODO: Strip itemprop if we aren't descendants of an itemscope. |
866 | 814 | } |
867 | 815 | return $out; |
868 | 816 | } |
— | — | @@ -1486,7 +1434,10 @@ |
1487 | 1435 | * @return Array |
1488 | 1436 | */ |
1489 | 1437 | static function attributeWhitelist( $element ) { |
1490 | | - $list = Sanitizer::setupAttributeWhitelist(); |
| 1438 | + static $list; |
| 1439 | + if( !isset( $list ) ) { |
| 1440 | + $list = Sanitizer::setupAttributeWhitelist(); |
| 1441 | + } |
1491 | 1442 | return isset( $list[$element] ) |
1492 | 1443 | ? $list[$element] |
1493 | 1444 | : array(); |
— | — | @@ -1500,13 +1451,6 @@ |
1501 | 1452 | static function setupAttributeWhitelist() { |
1502 | 1453 | global $wgAllowRdfaAttributes, $wgHtml5, $wgAllowMicrodataAttributes; |
1503 | 1454 | |
1504 | | - static $whitelist, $staticInitialised; |
1505 | | - $globalContext = implode( '-', compact( 'wgAllowRdfaAttributes', 'wgHtml5', 'wgAllowMicrodataAttributes' ) ); |
1506 | | - |
1507 | | - if ( isset( $whitelist ) && $staticInitialised == $globalContext ) { |
1508 | | - return $whitelist; |
1509 | | - } |
1510 | | - |
1511 | 1455 | $common = array( 'id', 'class', 'lang', 'dir', 'title', 'style' ); |
1512 | 1456 | |
1513 | 1457 | if ( $wgAllowRdfaAttributes ) { |
— | — | @@ -1539,7 +1483,7 @@ |
1540 | 1484 | |
1541 | 1485 | # Numbers refer to sections in HTML 4.01 standard describing the element. |
1542 | 1486 | # See: http://www.w3.org/TR/html4/ |
1543 | | - $whitelist = array( |
| 1487 | + $whitelist = array ( |
1544 | 1488 | # 7.5.4 |
1545 | 1489 | 'div' => $block, |
1546 | 1490 | 'center' => $common, # deprecated |
— | — | @@ -1667,26 +1611,7 @@ |
1668 | 1612 | # 'title' may not be 100% valid here; it's XHTML |
1669 | 1613 | # http://www.w3.org/TR/REC-MathML/ |
1670 | 1614 | 'math' => array( 'class', 'style', 'id', 'title' ), |
1671 | | - ); |
1672 | | - |
1673 | | - if ( $wgHtml5 ) { |
1674 | | - # HTML5 elements, defined by: |
1675 | | - # http://www.whatwg.org/specs/web-apps/current-work/multipage/ |
1676 | | - $whitelist += array( |
1677 | | - 'data' => array_merge( $common, array( 'value' ) ), |
1678 | | - 'time' => array_merge( $common, array( 'datetime' ) ), |
1679 | | - |
1680 | | - // meta and link are only present when Microdata is allowed anyways |
1681 | | - // so we don't bother adding another condition here |
1682 | | - // meta and link are only valid for use as Microdata so we do not |
1683 | | - // allow the common attributes here. |
1684 | | - 'meta' => array( 'itemprop', 'content' ), |
1685 | | - 'link' => array( 'itemprop', 'href' ), |
1686 | 1615 | ); |
1687 | | - } |
1688 | | - |
1689 | | - $staticInitialised = $globalContext; |
1690 | | - |
1691 | 1616 | return $whitelist; |
1692 | 1617 | } |
1693 | 1618 | |
Index: trunk/phase3/includes/tidy.conf |
— | — | @@ -16,8 +16,3 @@ |
17 | 17 | quote-nbsp: yes |
18 | 18 | fix-backslash: no |
19 | 19 | fix-uri: no |
20 | | - |
21 | | -# Don't strip html5 elements we support |
22 | | -# html-{meta,link} is a hack we use to prevent Tidy from stripping <meta> and <link> used in the body for Microdata |
23 | | -new-empty-tags: html-meta, html-link |
24 | | -new-inline-tags: data, time |
Index: trunk/phase3/RELEASE-NOTES-1.20 |
— | — | @@ -22,8 +22,6 @@ |
23 | 23 | * (bug 34475) Add support for IP/CIDR notation to tablesorter |
24 | 24 | * (bug 27619) Remove preference option to display broken links as link? |
25 | 25 | * (bug 15404) Add support for sorting fractions in jquery.tablesorter |
26 | | -* The <data>, <time>, <meta>, and <link> elements are allowed within WikiText for use |
27 | | - with Microdata. |
28 | 26 | |
29 | 27 | === Bug fixes in 1.20 === |
30 | 28 | * (bug 30245) Use the correct way to construct a log page title. |