HTML entity codes in the body are getting encoded twice.
turns into  
.
<meta property="og:description" content="&amp;nbsp;This is what I heard them say:&amp;ldquo;You can have the others, but Tinashe comes with me.&amp;rdquo;&amp;ldquo;Why would you separate the kids? Especially Tinashe, who needs his brothers and sisters arou..." />
Facebook renders &amp;nbsp;
as
. I believe the module should be outputting &nbsp;
.
This seems to happen regardless of what text format is used. Tested with both 7.x-1.2 and latest dev release.
See here for an example: http://trope.com/imow/stories/broken-toys
Thanks!
Comments
Comment #0.0
eusonic CreditAttribution: eusonic commentedAdded code tags for clarity.
Comment #1
Raphael Apard CreditAttribution: Raphael Apard commentedSame problème for me.
It's works if I replace line 273 of opengraph_meta.common.inc :
$v = htmlspecialchars(htmlspecialchars_decode($v));
by :
$v = html_entity_decode($v, ENT_COMPAT, 'UTF-8');
Only " will be encoded, but i can't get correct a full encoded value.
Comment #2
eusonic CreditAttribution: eusonic commentedI fixed this by changing line 273 in opengraph_meta.common.inc
from:
$v = htmlspecialchars(htmlspecialchars_decode($v));
to:
$v = htmlspecialchars_decode($v);
Is there any reason why this will backfire on me?
Comment #3
k4v CreditAttribution: k4v commentedI can confirm this bug, is #2 a valid fix?
Comment #4
k4v CreditAttribution: k4v commentedComment #5
zerolab CreditAttribution: zerolab commentedthe fix from #1 worked for me. Plus it fixed a problem with the Facebook sharer which extracts titles from the
og:title
tag.Don't
would turn intoD't
(notice the apostrophe)Comment #6
Cameron Tod CreditAttribution: Cameron Tod commentedI can confirm the fix in #2 works locally too. I am about to push it to a live site so will report if there are any other issues.
I've rolled this up into a patch - eusonic I attributed the commit to you.
Comment #7
Cameron Tod CreditAttribution: Cameron Tod commentedUgh bad patch, sorry.
Comment #8
q2_faith CreditAttribution: q2_faith commentedthe fix from #1 worked for me. But replace
on
Comment #9
jim005 CreditAttribution: jim005 commented#7 works well for French content. Thanks !
Comment #10
louisjimenez CreditAttribution: louisjimenez commentedIs there a fix for 6.x-1.7 ? I am also having this issue at http://drupal.org/node/1826258#comment-7000638 . Thanks!
Comment #10.0
louisjimenez CreditAttribution: louisjimenez commentedEdited to be a little clearer.
Comment #11
chrisarusso CreditAttribution: chrisarusso commentedYes to number q2_faith: per PHP's documentation here: http://us2.php.net/manual/en/function.html-entity-decode.php
We clearly need ENT_QUOTES to handle both double and single quotes.
Module seems unattended. I'll patch if requested
Comment #12
wonder95 CreditAttribution: wonder95 commentedI ran into this same problem, and here's how we modified line 273 to get it to work.
Comment #13
Demian CreditAttribution: Demian commentedI had an og:title with an apostrophe and og:description with double quotation marks.
In my case, every solution above, was decoding either the apostrophe or the quotation marks, not both.
The modified line bellow was the solution
$v = htmlspecialchars(html_entity_decode($v, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
Comment #14
rick_p CreditAttribution: rick_p as a volunteer commentedI was experiencing HTML entities being displayed as text, showing up when content was shared via ShareThis or similar widgets, particularly with facebook’s sharer. However, this issue has manifested itself in other ways as noted above.
As illmasterc mentions above, ENT_QUOTES will convert both double and single quotes, so I have rolled the work Demian did (directly above) into a patch. I credited both.
Comment #15
BTMash CreditAttribution: BTMash as a volunteer commented@rick_p pointed me to this issue. I'm not sure why the issue status is on 'Patch - To be ported' as it was never committed to the repository. I'm setting it to 'needs work' based on the patch that @rick_p wrote (the patch works, it should just get cleaned up). See below.
Clean up the spacing here. This can be reverted back.
Remove the commented lines. And fix up spacing .
Comment #16
rick_p CreditAttribution: rick_p as a volunteer commentedCleaned up code as requested: Fixed spacing, removed comments, removed deprecated code.
Comment #17
rick_p CreditAttribution: rick_p as a volunteer commentedMissed a couple of tabbed spaces.
Comment #18
BTMash CreditAttribution: BTMash as a volunteer commentedUpdated code looks great.