jenkins-bot has submitted this change and it was merged.

Change subject: Bug 50831: Support broken </br>
......................................................................


Bug 50831: Support broken </br>

This is pretty common and easy to support.

Without selser, this will round-trip without the broken /. With selser, there
will not be any diff at all.

Also added a test. html2html round-tripping is currently broken for new
<p><br></p>, which is tracked in bug 51055.

Change-Id: I293b7e9fc5e90abaa755d0efa90c4d5bbe5753cb
---
M js/lib/pegTokenizer.pegjs.txt
M js/tests/parserTests.txt
2 files changed, 20 insertions(+), 3 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/lib/pegTokenizer.pegjs.txt b/js/lib/pegTokenizer.pegjs.txt
index 9e9d059..b6626c9 100644
--- a/js/lib/pegTokenizer.pegjs.txt
+++ b/js/lib/pegTokenizer.pegjs.txt
@@ -1646,9 +1646,13 @@
     selfclose:"/"?
     ">" {
         name = name.join('');
-        var lcName = name.toLowerCase();
-        var isVoidElt = Util.isVoidElement( lcName ),
-            res = buildXMLTag(name, lcName, attribs, end, selfclose !== '' || 
isVoidElt, [pos0, pos]);
+        var lcName = name.toLowerCase(),
+            isVoidElt = Util.isVoidElement( lcName );
+        // Support </br>
+        if (lcName === 'br' && end) {
+            end = '';
+        }
+        var res = buildXMLTag(name, lcName, attribs, end, selfclose !== '' || 
isVoidElt, [pos0, pos]);
 
         // change up data-attribs in one scenario
         // void-elts that aren't self-closed ==> useful for accurate RT-ing
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 546d935..70f487f 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -4787,6 +4787,8 @@
 
 !! test
 Broken br tag sanitization
+!! options
+php
 !! input
 </br>
 !! result
@@ -4794,6 +4796,17 @@
 </p>
 !! end
 
+# TODO: Fix html2html mode (bug 51055)!
+!! test
+Parsoid: Broken br tag recognition
+!! options
+parsoid=wt2html
+!! input
+</br>
+!! result
+<p><br></p>
+!! end
+
 !! test
 Incorrecly removing closing slashes from correctly formed XHTML
 !! input

-- 
To view, visit https://gerrit.wikimedia.org/r/72684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I293b7e9fc5e90abaa755d0efa90c4d5bbe5753cb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to