-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
HTML tags in image alt text causes formatting issues for the following block #8779
Comments
I experienced the same issue today and wanted to add my test case, especially since it just includes a special character, but I wasn't writing HTML markup.
Here's how it looked in Chrome Dev Tools: |
I just encountered this issue today myself. I was going to report an issue, but then I found this one, so I'll put my drafted description here. There seems to be an issue with how Gutenberg serializes HTML attributes that contain tags inside of them (e.g. for developer docs). For example, given this <!-- wp:list -->
<ul><li>The result of the parsed styles is then <strong>minified, serialized, and stored in a <a rel="noreferrer noopener" aria-label="Collects inline styles and outputs them in the <amp-custom> stylesheet.
Fetch all external stylesheets (except for whitelisted fonts), collect all style elements in the document, and create style rules from inline style attributes
Parse/process the collected styles to ensure that:
There are no invalid at-rules and no disallowed CSS properties
Relative paths for background images are absolute
Any !important qualifier is transformed into style rules with higher-specificity selectors
If the result is larger than AMP’s 50KB limit, as CSS tree-shaking algorithm is applied
If after tree-shaking there is still more than 50KB, then any stylesheet that takes the total over 50KB will be omitted.
The result of the parsed styles is then minified, serialized, and stored in a transient, which are a simple and standardized way in WordPress for storing cached data in the database, temporarily by giving it a custom name and a timeframe after which it will expire and be deleted
Construct the style[custom] element to be added to the <head> (opens in a new tab)" href="https://codex.wordpress.org/Transients_API" target="_blank">transient</a></strong>, which are a simple and standardized way in WordPress for storing cached data in the database, temporarily by giving it a custom name and a timeframe after which it will expire and be deleted</li></ul>
<!-- /wp:list --> The In visual editing mode, the block looks fine: But as soon as I look at the post on the frontend, it is clear that all is not fine: In looking at the HTML rendered on the frontend, it seems that Gutenberg's HTML serializer fails by continuing to encode attribute double quotes as Expected behavior The edit function and save function should serialize HTML consistently. Tested against |
I've experienced the same issue. I've tried describing some hierarchy in the "alt" textarea for an image entering the ">" character, which broke my layout. This should get escaped as an html entity when added to the markup. |
When an image block has an alternative text with HTML markup (or anything resembling it) in it, the following block loses its styling.
Replication:
My<br>text
, butMy<awesome-tag>text
for exampleWhen viewing the page now, you will see that the image is there, but the paragraph block does not have its styles.
Images:
Without markup:
With markup:
There appears to be something funky going on with escaping values or something here. Sure markup isn't supported in alt texts, but users write strange things and we obviously need to get the escaping/sanitizing right.
The text was updated successfully, but these errors were encountered: