Opened 4 years ago
Last modified 3 months ago
#53860 new enhancement
REST API returns special characters as Unicode Decimal Code
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | 5.8 |
Component: | REST API | Keywords: | has-patch |
Focuses: | Cc: |
Description
When using the wordpress rest api, the api returns special characters as unicode decimal code instead of the correct character.
How to reproduce:
create fresh wordpress install and a new post with "&" in the title.
Query http://[url]/wp-json/wp/v2/posts and check post.title.rendered field
Instead of just "&" it will display "&# 038;" (without the space)
It would be optimal if this would be converted serverside.
Change History (2)
This ticket was mentioned in Slack in #meta by sergey. View the logs.
4 years ago
This ticket was mentioned in PR #8281 on WordPress/wordpress-develop by @gsayed786.
3 months ago
#2
- Keywords has-patch added
Note: See
TracTickets for help on using
tickets.
Description
get_the_title( $post->ID ) retrieves the post title.
wp_kses_decode_entities()
will decode any HTML entities (like & → &) in the title.This change will ensure that any special characters in the title, like &, are properly decoded before being returned in the REST API response.
Now, the title.rendered field in the REST API response will return the decoded title with the correct characters like &, instead of the Unicode entities.
Trac ticket: https://core.trac.wordpress.org/ticket/53860