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 · 4 comments

Comments

Projects
None yet
2 participants
@westonruter
Copy link
Member

commented May 14, 2019

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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>"
@westonruter

This comment has been minimized.

Copy link
Member Author

commented May 14, 2019

So the blame lies entirely with wptexturize()?

@aduth

This comment has been minimized.

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.