-
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
Post title renders escaped/encoded characters parsed by wp_kses filter #20490
Comments
It's tricky, and not immediately clear to me what the best approach would be. As you note, there are challenges with simply decoding entities of the title. And there may be cases that a user with the correct permissions makes a conscious choice to include entities in the title. Should we support that? On glance, possible directions may include one of:
Other items to investigate:
For what it's worth #19955 was simply a revert of #18616. It should be expected that the behavior as it exists today is the same as has always been for all stable WordPress releases. Those changes to escaping affected versions of the plugin between Gutenberg 7.0 and 7.4. |
That's great to know, this makes coming up with a fix feel a bit less urgent :)
That's a great question! A possibly awkward thing to do would be to check the capability of the user that last edited the post before decoding, but that feels like a level of complexity that could be particularly fraught. As for the number of characters affected, I'll investigate further next week and compare against the classic editor, but so far from taking a look through Next week I'll have a play with decoding the title on post load. Dealing with user permissions feels a tricky one because the permissions of a user editing a post might be different from the permissions of someone who created the post. I'll give this some more thought, too. Thanks for the extra insight @aduth! |
Part of the reason I was wondering about which characters are affected is in how that might impact how we choose to implement any decoding. For example, if it only impacts the ampersand, then maybe we don't need to use the full |
Short answer: It wasn't 😅 Upstream (from 2009): https://core.trac.wordpress.org/ticket/11311 |
I've begun to explore a solution at #20887 |
This is creating quite a lot of confusion for less-technical people. They don't know what escaped html entities are, and seeing that the title changes with weird text suddenly is quite confusing for them. |
Noting that this is also an issue for all block attributes, which are passed through kses and have ampersands replaced with (Image is of a Yoast SEO block, for illustrative purposes. I edited an article as an "author" role, which does not have the |
@andrewserong, I can no longer reproduce the original issue. So let's close this issue. |
@Mamaduka I can still reproduce the issue. |
@chrisvanpatten, for the Post Title or in components like |
Trac has a similar report today about the Site Editor (which probably should have its own issue). |
@sabernhardt, that issue is fixed in the Gutenberg trunk, and I just marked PR for backporting into a minor release. Thanks for bringing this up! |
Describe the bug
In a WordPress multisite install, most users do not have the
unfiltered_html
capability, so saved post titles will be filtered bywp_kses
as thetitle_save_pre
filtered is applied along with other filters inkses_init_filters()
.This means that saving an unencoded post title like
"This & that"
will become"This & that"
in the database. In Gutenberg, immediately upon saving, the post title currently gets rendered in its unescaped form after being parsed bywp_kses
on the backend.To reproduce
Steps to reproduce the behavior:
wp-env
so tested using VVV)/wp-admin/network.php
, set up the multisite and update yourwp-config.php
, and you have a multisite instance running, go to create a new post on one of your sites."This & that"
, click publish and the title will now be rendered as"This & that"
Expected behavior
The post title to be decoded for display and editing.
Screenshots
Desktop (please complete the following information):
Additional context
I'm happy to keep investigating this one and (try to) come up with a fix. Initially I was thinking of just wrapping the
value={ title }
in thePostTitle
component withdecodeEntities
like it was previously, however this results in strange behaviour if you start writing something like&
where the title gets decoded as you type. Ideally we want the decoding of the title to happen only when fetching the data from the server. I'm not that familiar with this area, so any pointers (or if anyone else want to have a go) will be much appreciated!The text was updated successfully, but these errors were encountered: