Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characters for greater than and less than are not encoded as entities in attribute values #15636

Open
westonruter opened this issue May 14, 2019 · 6 comments
Labels
[Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Saving Related to saving functionality [Type] Bug An existing feature does not function as intended

Comments

@westonruter
Copy link
Member

When adding > or < into an attribute value as follows:

<!-- wp:paragraph -->
<p><abbr title="1 &gt; 2">False</abbr> and <abbr title="1 &lt; 2">True</abbr></p>
<!-- /wp:paragraph -->

The serializer forces them to be > and < respectively.

<!-- wp:paragraph -->
<p><abbr title="1 > 2">False</abbr> and <abbr title="1 < 2">True</abbr></p>
<!-- /wp:paragraph -->

This gets rendered by WordPress as:

<p><abbr title="1 > 2&#8243;>False</abbr> and <abbr title="1 < 2">True</abbr></p>

The “False and” text is erroneously consumed be the attribute:

image

In this case, it seems to be a problem with wptexturize(), as it is converting the attribute closing " into &#8243;.

But if the block serializer output > as &gt; then this symptom could be avoided.

Possible regression after #9963.

Relates to #9915, #8779, #12683.

Tested in v5.7.0-rc.1.

@aduth
Copy link
Member

aduth commented May 14, 2019

Technically it would be a duplicate of #12683, though the earlier issue was intended to have been closed as a result of the merge of #9963.

@aduth aduth added [Component] Serializer [Type] Bug An existing feature does not function as intended labels May 14, 2019
@aduth
Copy link
Member

aduth commented May 14, 2019

I don't think it's entirely a regression of #9963, in that the element serializer itself is not the culprit, and it does still encode the characters.

I think the issue is a combination of RichText.Content effectively bypassing the serializer using RawHTML (source) and the behavior of the browser DOM in parsing a the paragraph contents as HTML, where &gt; is normalized in this context to > (because, as noted in #9963, it is not invalid).

var d = document.createElement( 'div' );
d.innerHTML = '<p><abbr title="1 &gt; 2">False</abbr> and <abbr title="1 &lt; 2">True</abbr></p>';
console.log( d.innerHTML );
// "<p><abbr title="1 > 2">False</abbr> and <abbr title="1 < 2">True</abbr></p>"

@aduth aduth added [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels May 14, 2019
@westonruter
Copy link
Member Author

So the blame lies entirely with wptexturize()?

@aduth
Copy link
Member

aduth commented May 15, 2019

So the blame lies entirely with wptexturize()?

Technically it always has 😆 #9963 was always a bandaid workaround because nobody dared touch the texturize function.

https://core.trac.wordpress.org/ticket/45387

@ellatrix
Copy link
Member

Anything actionable? Is this still an issue?

@westonruter
Copy link
Member Author

@ellatrix This is still an issue as of v7.1.0-rc.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Saving Related to saving functionality [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants