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

Fix encoded characters in term labels in Instant Results #3113

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

JakePT
Copy link
Contributor

@JakePT JakePT commented Nov 7, 2022

Description of the Change

The data for taxonomy term aggregations is send to Elasticsearch as encoded JSON, like this:

'{\"term_id\":236,\"slug\":\"blue\",\"name\":\"Blue\",\"parent\":0,\"term_taxonomy_id\":236,\"term_order\":0}'

This causes some characters, such as ampersands, inside the name field to be encoded as HTML entities. This means that when terms are displayed as facet options in Instant Results these characters are displayed in their encoded form.

This fix uses the (tiny) @wordpress/html-entities package to decode these entities.

Closes #3097

How to test the Change

Create a term that includes an & character and assign it to a post. Add the term's taxonomy as a facet to Instant Results and search for the post. The & should appear as expected in the list of facet options, and not as &. The character should also appear correct in the active filter 'chip' when the term is applied as a filter.

Changelog Entry

Fixed - An issue where some characters in taxonomy terms would appear encoded when displayed in Instant Results.

Credits

Props @JakePT

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@JakePT JakePT added the module:instant-results Issues related to the Instant Results functionality label Nov 7, 2022
@JakePT JakePT added this to the 4.4.0 milestone Nov 7, 2022
@JakePT JakePT self-assigned this Nov 7, 2022
@JakePT JakePT changed the title Fix encoded characters in term labels. Fix encoded characters in term labels in Instant Results Nov 7, 2022
@JakePT JakePT mentioned this pull request Nov 7, 2022
4 tasks
@felipeelia felipeelia merged commit 75f0077 into develop Nov 7, 2022
@felipeelia felipeelia deleted the fix/3097-jacob branch November 7, 2022 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:instant-results Issues related to the Instant Results functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: In Instant Result, term labels are encoded if it contains special HTML character
2 participants