-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix creating templates for posts with long slugs #71838
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
Conversation
| className={ `${ baseCssClass }__info` } | ||
| > | ||
| { suggestion.link } | ||
| { safeDecodeURI( suggestion.link ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filterURLForDisplay will give us slightly different text, without the protocol.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +53 B (0%) Total Size: 1.95 MB
ℹ️ View Unchanged
|
In the post slugs themselves, non-latin has been supported for 20 years, at least that's what |
tyxla
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This solves the reported issue in my testing, and I'd only wish we had a test to ensure this doesn't happen again.
I'm happy to see this approach used in other places where it's necessary. No need to block this PR though IMO.
|
@jsnajdr, this is the ticket I was referring to - WordPress/wordpress-develop#3819. |
This code ( |
|
I'm going to merge now, acknowledging that there will be followups. |
|
Thanks, @jsnajdr! |



Fixes the following bug when creating a template for a single post:
รีวิว Secretlab MAGNUS Pro Lamborghini Edition: เมื่อโต๊ะเกมมิ่งไม่ใช่แค่โต๊ะ แต่คือ “Supercar” ในห้องคุณWhat happened?
wp_posts.post_name) is limited to 200 chars. The new post's slug will be longer than that, especially when urlencoded. But the PHPsanitize_title_with_dashesfunction in Core will correctly truncate it to 200 chars, carefully respecting boundaries of utf-8 multiple-byte characters and of urlencoded octets.single-post-${ postSlug }. Here we are acting on urlencodedpostSlugand the urlencoded template slug (now longer than 200 chars) will be sent as payload of the REST request that creates the template.sanitize_title_with_dashesis careful only when dealing with a string that's not urlencoded. It correctly truncates and encodes raw utf-8 characters. But an urlencoded string will be truncated bluntly, and we're left with a slug that's not a valid urlencoded string. It looks something like...%b8%81%e.create_itemfunction of the templates controller will crash. Requests to DELETE the new template will be rejected by the Apache server itself, because the URL contains the wrongly encoded slug.I'm fixing this by decoding the original post slug before appending the prefix. Then the REST request will contain a slug string with raw utf-8 characters, and
sanitize_title_with_dasheswill be able to truncate it nicely.We should also do a companion Core patch that addresses the crashes. But this Gutenberg fix is good enough to get rid of the issue.