Cscott has uploaded a new change for review. https://gerrit.wikimedia.org/r/72981
Change subject: Fix incorrect escaping of nested <em>, <strong>, <q>, <ruby>, and <bdo> ...................................................................... Fix incorrect escaping of nested <em>, <strong>, <q>, <ruby>, and <bdo> The parser, when given "<em>X<em>Y</em>Z</em>" was emitting "<p><em>X<em>Y</em>Z</em></p>". This is the same as bug 41545, but with a different set of tags. Note that the HTML spec (http://www.w3.org/TR/html5/text-level-semantics.html) gives an explicit meaning for nested <em>, <strong>, <q>, <ruby>, and <bdo>. There are other nestable tags (<b>, <i>, <s>, <u>, <cite>, <dfn>, <abbr>, <time>, <code>, <mark>, <rt>, <rp>, <bdi>) which I've chosen not to fix in this commit since the spec allows but does not give semantics for them. A wikipedian authoring content with these nested tags is probably making an error; the escaped content will make this obvious. Bug: 51081 Change-Id: Ia940ac54e9527bba7fee75d3bd91babee2f91c57 --- M includes/Sanitizer.php M tests/parser/parserTests.txt 2 files changed, 77 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/81/72981/1 diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 7400a5a..fa883fc 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -397,7 +397,7 @@ $htmlnest = array( # Tags that can be nested--?? 'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'font', 'big', 'small', 'sub', 'sup', 'span', - 'var', 'kbd', 'samp' + 'var', 'kbd', 'samp', 'em', 'strong', 'q', 'ruby', 'bdo' ); $tabletags = array( # Can only appear inside table, we will close them 'td', 'th', 'tr', diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 478b348..337342a 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1106,7 +1106,7 @@ !! end ### -### paragraph wraping tests +### paragraph wrapping tests ### !! test No block tags @@ -9504,6 +9504,81 @@ ### +### Nesting tests (see bug 41545, 50604, 51081) +### + +# This test case is fixed in Parsoid by domino 1.0.12. (bug 50604) +# Note that html2wt is considerably more difficult if we use <b> in +# the test case, instead of <big> +!! test +Ensure that HTML adoption agency algorithm is properly implemented. +!! input +<big>X<big>Y</big>Z</big> +!! result +<p><big>X<big>Y</big>Z</big> +</p> +!! end + +# This was bug 41545 in the PHP parser. +!! test +Nesting of <kbd> +!! input +<kbd>X<kbd>Y</kbd>Z</kbd> +!! result +<p><kbd>X<kbd>Y</kbd>Z</kbd> +</p> +!! end + +# The following cases were bug 51081 in the PHP parser. +# Note that there are some other nestable tags (b, i, etc) which are +# not covered; see bug 51081 for discussion. +!! test +Nesting of <em> +!! input +<em>X<em>Y</em>Z</em> +!! result +<p><em>X<em>Y</em>Z</em> +</p> +!! end + +!! test +Nesting of <strong> +!! input +<strong>X<strong>Y</strong>Z</strong> +!! result +<p><strong>X<strong>Y</strong>Z</strong> +</p> +!! end + +!! test +Nesting of <q> +!! input +<q>X<q>Y</q>Z</q> +!! result +<p><q>X<q>Y</q>Z</q> +</p> +!! end + +!! test +Nesting of <ruby> +!! input +<ruby>X<ruby>Y</ruby>Z</ruby> +!! result +<p><ruby>X<ruby>Y</ruby>Z</ruby> +</p> +!! end + +!! test +Nesting of <bdo> +!! input +<bdo>X<bdo>Y</bdo>Z</bdo> +!! result +<p><bdo>X<bdo>Y</bdo>Z</bdo> +</p> +!! end + + +### ### Media links ### @@ -16158,31 +16233,6 @@ </ul> !! end -# This test case is fixed by domino 1.0.12. -# Note that html2wt is considerably more difficult if we use <b> in -# the test case, instead of <big> -!! test -Ensure that HTML adoption agency algorithm is properly implemented. -!! options -!! input -<big>X<big>Y</big>Z</big> -!! result -<p><big>X<big>Y</big>Z</big> -</p> -!! end - -# The parsoid team believes the below behavior of the PHP parser to be -# a bug. -!! test -Document PHP parser behavior for HTML adoption agency test case. -!! options -php -!! input -<em>X<em>Y</em>Z</em> -!! result -<p><em>X<em>Y</em>Z</em> -</p> -!! end TODO: more images -- To view, visit https://gerrit.wikimedia.org/r/72981 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia940ac54e9527bba7fee75d3bd91babee2f91c57 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Cscott <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
