Page 1 of 1

Open Graph Content Plugin - ampersand encoding problem

Posted: 17 Aug 2026, 23:40
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!!!