#41208 closed defect (bug) (fixed)
Dashboard News & Events widget does not properly handle entities (e.g. en/em dash)
Reported by: | nickciske | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.0 | Priority: | low |
Severity: | normal | Version: | 4.8 |
Component: | Administration | Keywords: | has-patch commit |
Focuses: | ui, javascript | Cc: |
Description
"WordCamp Minneapolis – St. Paul, Minnesota, USA" is displayed as "WordCamp Minneapolis – St. Paul, Minnesota, USA"
Attachments (8)
Change History (28)
#1
@
7 years ago
On Chrome on Windows, I see the same result for the Minneapolis event in the first screenshot from nickciske, but I do see em- and en-dashes and at-signs properly for other events (screenshots attached).
#2
@
7 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Owner set to iandunn
- Priority changed from normal to low
- Status changed from new to accepted
I'm seeing this too. I haven't had time to really dig into it, but the –
entity is returned by the w.org API, which seems appropriate at first glance.
My first guess would be that {{
is preventing the entity from being rendered. Running the data through htmlspecialchars_decode()
before it gets returned from get_events()
might be a good fix. I think that'd be safe, since it'd still be passed through {{
, but we'd need to verify that.
#3
@
7 years ago
I think this issue may have been resolved by Meetup itself. I tried editing one of my future meetups (https://www.meetup.com/WordpressDevSeacoast/events/243889267/ - on 1/11/18) to contain an endash or an emdash and it shows properly both in Meetup and also when I looked at it in the dashboard (search for "Nottingham") and the "Users — TBD" meetup shows fine.
Steps: What I did was paste the entity directly into the meetup title. Then I waited for the widget to refresh itself (I deleted my local transients, but it seems like Meetup or something up the chain was caching the titles for a bit). I am able to find my meetup at the moment by searching for "Nottingham" (this narrows the search so I can see further ahead to the Jan meetup). Once the updated "Users — TBD" title appeared in the widget, it was displaying correctly.
#6
@
3 years ago
- Milestone changed from Future Release to 5.9
Adding it to the upcoming major milestone for consideration. A similar issue was faced recently with Santa Catarina - Brazil.
#9
@
3 years ago
- Keywords needs-refresh added
- Milestone changed from 5.9 to 6.0
From ticket:53851#comment:6 :
I agree w/ Jake about keeping the escaping, but ticket:41208#comment:2 might work.
#10
@
3 years ago
Justr noting that the patch proposed above doesn't work in most case since unescape()
only handles a small amount of entities (source: http://underscorejs.org/#unescape).
#11
@
3 years ago
Sames goes for htmlspecialchars_decode
(source: https://www.php.net/manual/fr/function.htmlspecialchars-decode.php).
I think we need to use html_entity_decode
.
This ticket was mentioned in PR #2124 on WordPress/wordpress-develop by audrasjb.
3 years ago
#12
- Keywords needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/41208
#13
@
3 years ago
The above PR fixes the issue.
## How to test
Step 1: simulate the issue
Using the PR above, replace this line:
$event['title'] = html_entity_decode( $event['title'] );
with:
$event['title'] = 'test – testing' );
See that it displays the raw HTML entity on the dashboard.
Step 2: fix the issue
Now replace the line with:
$event['title'] = html_entity_decode( 'test – testing' );
See that it displays: test – testing
.
#15
@
3 years ago
For testing, I wanted to keep both the original code and the patch changes intact, so I edited the $events
array immediately at the beginning of the trim_events()
function. (The PR diff applied changes around this.)
$events[0]['title'] = '“test – testing” …'; $events[1]['title'] = 'Users — TBD'; $events[1]['type'] = 'wordcamp'; $events[2]['title'] = '« L’Événement » à Nîmes';
#16
@
3 years ago
Thanks for testing @sabernhardt.
So according to your test case, I assume we're good to go with this patch?
#17
@
3 years ago
This patch probably is ready, though I did not add the commit
keyword in case someone else would want to test additional characters and/or add feedback.
The only identified problems occur with the dash character codes, and the PR fixes those plus others (both numeric codes and entities).
#18
@
3 years ago
- Keywords commit added
Thanks @SergeyBiryukov, @ocean90, @sabernhardt for the review 👍
3 years ago
#20
Committed in https://core.trac.wordpress.org/changeset/52608
Screenshot of issue