Open Graph Content Plugin - ampersand encoding problem

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
pixelhexe
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Mar 2012, 13:49

Open Graph Content Plugin - ampersand encoding problem

Post by pixelhexe »

Hello Jan,

I found a small encoding issue in Phoca Open Graph Content Plugin 6.0.2 on Joomla 5.4.7.

My Joomla configuration contains a website name with an "&", let's say:

`A & B`

Joomla itself outputs this correctly in the page title:

`<title>A &amp; B</title>`

However, Phoca Open Graph generates:

`<meta property="og:site_name" content="A &amp;amp; B">`

So the ampersand is encoded twice.

I traced this to `renderTag()` in `plugins/content/phocaopengraph/phocaopengraph.php`.

The relevant code is:

Code: Select all

<?php
$value = strip_tags(html_entity_decode($value));

...

$document->setMetadata(
    htmlspecialchars($name, ENT_COMPAT, 'UTF-8'),
    htmlspecialchars($value, ENT_COMPAT, 'UTF-8'),
    $typeString
);
?> 
If I change the second part to:

Code: Select all

<?php
$document->setMetadata(
    htmlspecialchars($name, ENT_COMPAT, 'UTF-8'),
    $value,
    $typeString
);
?> 
the output becomes correct:

`<meta property="og:site_name" content="A &amp; B">`

So it seems that `$value` should not be passed through `htmlspecialchars()` before `setMetadata()`, because Joomla encodes the value when generating the meta tag.

The `addCustomTag()` branch still needs its own `htmlspecialchars()`, since it builds the HTML string directly.

I tested this on Joomla 5.4.7 with Phoca Open Graph Content Plugin 6.0.2.

Maybe this could be fixed in a future version.

Thank you very much for all your efforts!!!
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49556
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open Graph Content Plugin - ampersand encoding problem

Post by Jan »

Hi, try to test version 6.0.3 and let me know:
https://www.phoca.cz/download/78-phoca- ... aph-plugin
If you find Phoca extensions useful, please support the project
pixelhexe
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Mar 2012, 13:49

Re: Open Graph Content Plugin - ampersand encoding problem

Post by pixelhexe »

Thank you, Jan,
this solves the issue. :)

The problem also occurs in the Open Graph System Plugin. Could you fix it there as well?
Thank you once again!
Post Reply