Merge "Whitelist the <wbr> element."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Aug 2013 14:38:32 +0000 (14:38 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Aug 2013 14:38:32 +0000 (14:38 +0000)
1  2 
RELEASE-NOTES-1.22
includes/Sanitizer.php
tests/parser/parserTests.txt

diff --combined RELEASE-NOTES-1.22
@@@ -173,6 -173,7 +173,7 @@@ production
    specific purge.
  * (bug 25931) Add Special:RandomInCategory.
  * mediawiki.util: addPortletLink now supports passing a jQuery object as nextnode.
+ * <wbr> can now be used inside WikiText.
  
  === Bug fixes in 1.22 ===
  * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
    revision as second argument now, rather than just the current section.
  * (bug 49694) $wgSpamRegex is now also applied on the new section headline text
    adding a new topic on a page
 +* (bug 6200) line breaks in <blockquote> are handled like they are in <div>
  
  === API changes in 1.22 ===
  * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
    with the content.
  * (bug 51342) prop=imageinfo iicontinue now contains the dbkey, not the text
    version of the title.
 +* (bug 52538) action=edit will now use empty text instead of the contents
 +  of section 0 when passed prependtext or appendtext with section=new.
  
  === Languages updated in 1.22===
  
diff --combined includes/Sanitizer.php
@@@ -56,7 -56,7 +56,7 @@@ class Sanitizer 
         * As well as &apos; which is only defined starting in XHTML1.
         * @private
         */
 -      static $htmlEntities = array(
 +      private static $htmlEntities = array(
                'Aacute'   => 193,
                'aacute'   => 225,
                'Acirc'    => 194,
        /**
         * Character entity aliases accepted by MediaWiki
         */
 -      static $htmlEntityAliases = array(
 +      private static $htmlEntityAliases = array(
                'רלמ' => 'rlm',
                'رلم' => 'rlm',
        );
  
        /**
         * Lazy-initialised attributes regex, see getAttribsRegex()
 +       * @private
         */
 -      static $attribsRegex;
 +      private static $attribsRegex;
  
        /**
         * Regular expression to match HTML/XML attribute pairs within a tag.
         * removes HTML comments
         * @private
         * @param $text String
 -       * @param $processCallback Callback to do any variable or parameter replacements in HTML attribute values
 +       * @param $processCallback Callback to do any variable or parameter
 +       *        replacements in HTML attribute values
         * @param array $args for the processing callback
         * @param array $extratags for any extra tags to include
         * @param array $removetags for any tags (default or extra) to exclude
         * @return string
         */
 -      static function removeHTMLtags( $text, $processCallback = null, $args = array(), $extratags = array(), $removetags = array() ) {
 +      static function removeHTMLtags( $text, $processCallback = null,
 +              $args = array(), $extratags = array(), $removetags = array()
 +      ) {
                global $wgUseTidy, $wgAllowMicrodataAttributes, $wgAllowImageTag;
  
                static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags,
                                'kbd', 'samp', 'data', 'time', 'mark'
                        );
                        $htmlsingle = array(
-                               'br', 'hr', 'li', 'dt', 'dd'
+                               'br', 'wbr', 'hr', 'li', 'dt', 'dd'
                        );
                        $htmlsingleonly = array( # Elements that cannot have close tags
-                               'br', 'hr'
+                               'br', 'wbr', 'hr'
                        );
                        if ( $wgAllowMicrodataAttributes ) {
                                $htmlsingle[] = $htmlsingleonly[] = 'meta';
                                # $params: String between element name and >
                                # $brace: Ending '>' or '/>'
                                # $rest: Everything until the next element of $bits
 -                              if ( preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ) ) {
 +                              if ( preg_match( '!^(/?)([^\\s/>]+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ) ) {
                                        list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
                                } else {
                                        $slash = $t = $params = $brace = $rest = null;
                        while ( substr( $text, $spaceStart + $spaceLen, 1 ) === ' ' ) {
                                $spaceLen++;
                        }
 -                      if ( substr( $text, $spaceStart, 1 ) === "\n" and substr( $text, $spaceStart + $spaceLen, 1 ) === "\n" ) {
 +                      if ( substr( $text, $spaceStart, 1 ) === "\n"
 +                              && substr( $text, $spaceStart + $spaceLen, 1 ) === "\n" ) {
                                # Remove the comment, leading and trailing
                                # spaces, and leave only one newline.
                                $text = substr_replace( $text, "\n", $spaceStart, $spaceLen + 1 );
                                continue;
                        }
  
 -                      //RDFa and microdata properties allow URLs, URIs and/or CURIs. check them for sanity
 -                      if ( $attribute === 'rel' || $attribute === 'rev' ||
 -                              $attribute === 'about' || $attribute === 'property' || $attribute === 'resource' || #RDFa
 -                              $attribute === 'datatype' || $attribute === 'typeof' ||                             #RDFa
 -                              $attribute === 'itemid' || $attribute === 'itemprop' || $attribute === 'itemref' || #HTML5 microdata
 -                              $attribute === 'itemscope' || $attribute === 'itemtype' ) {                         #HTML5 microdata
 -
 +                      // RDFa and microdata properties allow URLs, URIs and/or CURIs.
 +                      // Check them for sanity.
 +                      if ( $attribute === 'rel' || $attribute === 'rev'
 +                              # RDFa
 +                              || $attribute === 'about' || $attribute === 'property'
 +                              || $attribute === 'resource' || $attribute === 'datatype'
 +                              || $attribute === 'typeof'
 +                              # HTML5 microdata
 +                              || $attribute === 'itemid' || $attribute === 'itemprop'
 +                              || $attribute === 'itemref' || $attribute === 'itemscope'
 +                              || $attribute === 'itemtype'
 +                      ) {
                                //Paranoia. Allow "simple" values but suppress javascript
                                if ( preg_match( self::EVIL_URI_PATTERN, $value ) ) {
                                        continue;
                        if ( $attribute === 'href' || $attribute === 'src' ) {
                                if ( !preg_match( $hrefExp, $value ) ) {
                                        continue; //drop any href or src attributes not using an allowed protocol.
 -                                                //NOTE: this also drops all relative URLs
 +                                      // NOTE: this also drops all relative URLs
                                }
                        }
  
                );
  
                if ( $wgAllowRdfaAttributes ) {
 -                      #RDFa attributes as specified in section 9 of http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014
 +                      # RDFa attributes as specified in section 9 of
 +                      # http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014
                        $common = array_merge( $common, array(
                                'about', 'property', 'resource', 'datatype', 'typeof',
                        ) );
                }
  
                if ( $wgAllowMicrodataAttributes ) {
 -                      # add HTML5 microdata tags as specified by http://www.whatwg.org/html/microdata.html#the-microdata-model
 +                      # add HTML5 microdata tags as specified by
 +                      # http://www.whatwg.org/html/microdata.html#the-microdata-model
                        $common = array_merge( $common, array(
                                'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype'
                        ) );
                        # 9.3.2
                        'br'         => array( 'id', 'class', 'title', 'style', 'clear' ),
  
+                       # http://www.whatwg.org/html/text-level-semantics.html#the-wbr-element
+                       'wbr'        => array( 'id', 'class', 'title', 'style' ),
                        # 9.3.4
                        'pre'        => array_merge( $common, array( 'width' ) ),
  
                        'td'         => array_merge( $common, $tablecell, $tablealign ),
                        'th'         => array_merge( $common, $tablecell, $tablealign ),
  
 -                      # 12.2 # NOTE: <a> is not allowed directly, but the attrib whitelist is used from the Parser object
 +                      # 12.2
 +                      # NOTE: <a> is not allowed directly, but the attrib
 +                      # whitelist is used from the Parser object
                        'a'          => array_merge( $common, array( 'href', 'rel', 'rev' ) ), # rel/rev esp. for RDFa
  
                        # 13.2
@@@ -866,51 -866,14 +866,51 @@@ Non-html5 tags should be accepte
  !! end
  
  !! test
- <wbr> isn't (yet) valid wikitext (bug 52468)
+ <wbr> is valid wikitext (bug 52468)
  !! input
  <wbr>
  !! result
- <p>&lt;wbr&gt;
+ <p><wbr />
  </p>
  !! end
  
 +# <strike> is HTML4, <s> is HTML4/5.
 +!! test
 +<s> or <strike> for strikethrough
 +!! input
 +<strike>strike</strike>
 +
 +<s>s</s>
 +!! result
 +<p><strike>strike</strike>
 +</p><p><s>s</s>
 +</p>
 +!! end
 +
 +!! test
 +Non-word characters don't terminate tag names (bug 17663, 40670, 52022)
 +!! input
 +<b→> doesn't work! </b>
 +
 +<bä> doesn't work! </b>
 +
 +<boo> works fine </b>
 +
 +<s.foo>foo</s>
 +
 +<s.foo>s.foo</s.foo>
 +
 +<sub-ID#1>
 +!! result
 +<p>&lt;b→&gt; doesn't work! &lt;/b&gt;
 +</p><p>&lt;bä&gt; doesn't work! &lt;/b&gt;
 +</p><p>&lt;boo&gt; works fine &lt;/b&gt;
 +</p><p>&lt;s.foo&gt;foo&lt;/s&gt;
 +</p><p>&lt;s.foo&gt;s.foo&lt;/s.foo&gt;
 +</p><p>&lt;sub-ID#1&gt;
 +</p>
 +!! end
 +
  ###
  ### Special characters
  ###
@@@ -1338,6 -1301,8 +1338,6 @@@ Regression with preformatted in <center
  
  !! end
  
 -# Expected output in the following test is not really expected (there should be
 -# <pre> in the output) -- it's only testing for well-formedness.
  !! test
  Bug 6200: Preformatted in <blockquote>
  !! input
  </blockquote>
  !! result
  <blockquote>
 - Blah
 +<pre>Blah
 +</pre>
 +</blockquote>
 +
 +!! end
 +
 +!! test
 +Bug 51086: Double newlines in blockquotes should be turned into paragraphs
 +!! input
 +<blockquote>
 +Foo
 +
 +Bar
 +</blockquote>
 +!! result
 +<blockquote>
 +<p>Foo
 +</p><p>Bar
 +</p>
 +</blockquote>
 +
 +!! end
 +
 +!! test
 +Bug 15491: <ins>/<del> in blockquote
 +!! input
 +<blockquote>
 +Foo <del>bar</del> <ins>baz</ins> quux
 +</blockquote>
 +!! result
 +<blockquote>
 +<p>Foo <del>bar</del> <ins>baz</ins> quux
 +</p>
 +</blockquote>
 +
 +!! end
 +
 +# Note that the p-wrapping is newline sensitive, which could be
 +# considered a bug: tidy will wrap only the 'Foo' in the example
 +# below in a <p> tag. (see comment 23-25 of bug #6200)
 +!! test
 +Bug 15491: <ins>/<del> in blockquote (2)
 +!! input
 +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
 +</blockquote>
 +!! result
 +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
  </blockquote>
  
  !! end
  </pre>
  </center>
  <blockquote>
 - foo
 +<pre>foo
 +</pre>
  </blockquote>
  <table><tr><td>
  <pre>foo
@@@ -10337,7 -10255,7 +10337,7 @@@ Expansion of multi-line templates in at
  !! end
  
  ###
 -### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
 +### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
  ###
  !! test
  Parser hook: empty input
@@@ -10502,7 -10420,7 +10502,7 @@@ array 
  !! end
  
  ###
 -### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
 +### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
  ###
  
  !! test
@@@ -12927,6 -12845,9 +12927,6 @@@ __NOEDITSECTION_
  </p>
  !! end
  
 -# Expected output in the following test is not necessarily expected (there
 -# should probably be <p> tags inside the <blockquote> in the output) -- it's
 -# only testing for well-formedness.
  !! test
  Bug 6200: blockquotes and paragraph formatting
  !! input
   baz
  !! result
  <blockquote>
 -foo
 +<p>foo
 +</p>
  </blockquote>
  <p>bar
  </p>
@@@ -13626,6 -13546,8 +13626,6 @@@ B</strong
  # Bug 6200: <blockquote> should behave like <div> with respect to line breaks
  !! test
  Bug 6200: paragraphs inside blockquotes (no extra line breaks)
 -!! options
 -disabled
  !! input
  <blockquote>Line one
  
@@@ -13638,6 -13560,8 +13638,6 @@@ Line two</blockquote
  
  !! test
  Bug 6200: paragraphs inside blockquotes (extra line break on open)
 -!! options
 -disabled
  !! input
  <blockquote>
  Line one
@@@ -13653,6 -13577,8 +13653,6 @@@ Line two</blockquote
  
  !! test
  Bug 6200: paragraphs inside blockquotes (extra line break on close)
 -!! options
 -disabled
  !! input
  <blockquote>Line one
  
@@@ -13668,6 -13594,8 +13668,6 @@@ Line tw
  
  !! test
  Bug 6200: paragraphs inside blockquotes (extra line break on open and close)
 -!! options
 -disabled
  !! input
  <blockquote>
  Line one
  !! end
  
  
 -# This fails in the PHP parser (see bug 40670,
 -# https://bugzilla.wikimedia.org/show_bug.cgi?id=40670), so disabled for it.
 +# This was a bug in the PHP parser (see bug 17663 and its dups,
 +# https://bugzilla.wikimedia.org/show_bug.cgi?id=17663)
  !! test
  Tag names followed by punctuation should not be recognized as tags
 -!! options
 -parsoid
  !! input
  <s.ome> text
  !! result