I was have an issue with Apostrophe's showing up in the meta tag of a page as

Turchenek's

The actual source code read: Turchenek's

I adjusted line 267 in open graph_meta.common.inc to:

 case self::TITLE:
            $v = htmlspecialchars_decode($v);
            break;

Checking the meta output here:
http://www.google.com/webmasters/tools/richsnippets

Is this correct? Is this how it is supposed to be with single quotes in the title?

Comments

hiddentao’s picture

This might be worth fixing on a more general level.

skrichten’s picture

Yes definitely,
We have this same issue, do you plan to have a fix in the next release and if so, when do you think that will be?

jamix’s picture

StatusFileSize
new847 bytes

The problem here is that htmlspecialchars_decode() only decodes a small subset of HTML entities, and ' is not among them unless the ENT_QUOTES flag is set. A better solution seems to be to use Drupal's decode_entities() instead, which will decode all HTML entities via html_entity_decode(). See the attached patch.

Jerimee’s picture

Same problem here. Please commit a change like those proposed.

jamix’s picture

StatusFileSize
new903 bytes

In fact, double quotes still appeared encoded even with the patch from #3 applied. It turned out that running the title through htmlspecialchars() isn't necessary because HTML encoding is done in D7's theme_html_tag(). The attached patch removes the htmlspecialchars() call while making sure that in D6, proper escaping is done before the meta tag is output.

torotil’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Hi,

I'm the new maintainer of opengraph_meta. Sorry for the long silence in the issue queue.

Sadly I don't have the resources to care for the Drupal 6 version. Unless and until someone steps up to maintain it I'm therefore closing all D6 issues as WONTFIX.

Feel free to re-open the issue if it is still valid in one of the Drupal 7 branches.

Thanks!

arnoldbird’s picture

Version: 6.x-1.6 » 7.x-1.3
Status: Closed (won't fix) » Active

I'm running into this same issue in 7.x-1.3.

arnoldbird’s picture

I implemented the first of the two code changes in the patch in #5 in version 7.x-1.3. This seems to resolve the problem, but I'm not sure. The change does prevent the double-encoding of a single quote in the title. Meanwhile, though, I'm not totally sure if these characters should be encoded at all when I look at the page source. I don't know the reasoning behind encoding a character in a meta tag.

It's beyond the scope of this module, but just for background, I'm trying to implement a like button as described at https://developers.facebook.com/docs/plugins/like-button -- I'm finding that in the popup box that appears when I click the like button, the character encoding is getting passed to the output as if it is double-encoded in the meta tag. However, that happens whether or not the character is double encoded in the metatag.

arnoldbird’s picture

On further review, I don't think a single quote should be encoded at all in the meta tag. When I look at the page source, I should see this...

<meta property="og:title" content="Ryan's Test" />

...rather than...

<meta property="og:title" content="Ryan&#039;s Test" />

Am I right so far? The latter is what I'm seeing, so I'd say this is a valid bug and still needs fixing.

sivaprasadc’s picture

Hi Guys,

The Patch #5 is worked fine for me. Thank you All.