Repository navigation
Treat xmp as a raw text element - #287
Open
mokshupadhyay wants to merge 1 commit into
Open
mokshupadhyay wants to merge 1 commit into
mokshupadhyay wants to merge 1 commit into
Conversation
The xmp entry had the value 20 (AUTOCLOSE_P | TEXT_RCDATA) while its comment said raw text. Character references inside xmp were decoded when parsing and its text was escaped when serializing, so <xmp><b></xmp> came back with different content. The HTML standard parses xmp with the generic raw text element parsing algorithm and serializes its text literally, like script and style.
Author
|
Hi @goetas, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Elements::$html5listedxmpwith the value20, which isAUTOCLOSE_P | TEXT_RCDATA(16 + 4), although the comment next to it says raw text. So<xmp>was handled like<textarea>/<title>: character references inside it were decoded when parsing, and its text was escaped when saving. In HTML,xmpis a raw text element likescriptandstyle(the text is taken and written back literally), so the content changed on a round trip.The value is now
18(AUTOCLOSE_P | TEXT_RAW, 16 + 2), and the comment says that.Real output of
loadHTMLFragment()thensaveHTML(), next to what PHP 8.4+'s built-in HTML5 parser (Dom\HTMLDocument,body->innerHTML) gives for the same input:Dom\HTMLDocument<xmp>a & b <i> <b>c</b></xmp><xmp>a & b <i> <b>c</b></xmp><xmp>a & b <i> <b>c</b></xmp><xmp><p>x</p></xmp>after<xmp><p>x</p></xmp>after<xmp><p>x</p></xmp>after<xmp>©</xmp><xmp>©</xmp><xmp>©</xmp>Tests:
Html5Test::testXmpIsRawText(text content is not decoded, and the fragment and a document round-trip unchanged) and two assertions inElementsTest::testIsA(xmpisTEXT_RAW, notTEXT_RCDATA). Both tests fail onmasterand pass now.vendor/bin/phpunitpasses (176 tests, 2186 assertions), run on PHP 8.6 with deprecation notices silenced; I did not run it on PHP 7.4.