if you have quotes (") in your articles title or article-text
joomla makes " out of them ... (PHP: htmlspecialchars)
so far so good ...
but then in the og: tags
there appears "
(maybe double execution of (PHP: htmlspecialchars) ? -> maybe use the $double_encode = false parameter of htmlspecialchars)
opengraph conten plugin: wrong handling of " (" ")
-
- Phoca Member
- Posts: 45
- Joined: 13 May 2009, 14:53
-
- Phoca Member
- Posts: 45
- Joined: 13 May 2009, 14:53
Re: opengraph conten plugin: wrong handling of " (" ")
it seems that the call
$document->setMetadata
in .../plugins/content/phocaopengraph/phocaopengraph.php
on line 111
does already a htmlspecialchars conversion on its own* (?):
Test: if I insert
at line 111 for test purposes,
in the html head shows correctly:
strangely enough:
*this works for the $value part only (second argument of $document->setMetadata)
but not for the name part (first argument of $document->setMetadata)
-----------
using Joomla 5.3.0 / PHP 8.4.3
$document->setMetadata
in .../plugins/content/phocaopengraph/phocaopengraph.php
on line 111
does already a htmlspecialchars conversion on its own* (?):
Test: if I insert
Code: Select all
$document->setMetadata(htmlspecialchars($name, ENT_COMPAT, 'UTF-8'), '& < > "', $typeString);
in the html head shows correctly:
Code: Select all
<meta property="og:title" content="& < > "">
*this works for the $value part only (second argument of $document->setMetadata)
but not for the name part (first argument of $document->setMetadata)
-----------
using Joomla 5.3.0 / PHP 8.4.3
-
- Phoca Member
- Posts: 45
- Joined: 13 May 2009, 14:53
Re: opengraph conten plugin: wrong handling of " (" ")
I think the second/double htmlspecialchars happens (in Joomla core) here:
https://github.com/joomla/joomla-cms/bl ... r.php#L158
"type" and "name" are left unchanged while "content" gets a htmlspecialchars conversion ...
https://github.com/joomla/joomla-cms/bl ... r.php#L158
Code: Select all
$buffer .= $tab . '<meta ' . $type . '="' . $name . '" content="'. htmlspecialchars($contents, ENT_COMPAT, 'UTF-8') . '">' . $lnEnd;
- Jan
- Phoca Hero
- Posts: 48736
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: opengraph conten plugin: wrong handling of " (" ")
Hi, are you sure, that "setMetadata" method uses this function?
Jan
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 45
- Joined: 13 May 2009, 14:53
Re: opengraph conten plugin: wrong handling of " (" ")
no not sure,
but if I remove* the
the "htmlspecialchars" from the $document->setMetadata calls in
".../plugins/content/phocaopengraph/phocaopengraph.php"
everything works as expected even when inserting the characters " < > & in the title or desription
*(for the $value part only (second argument of $document->setMetadata)
but not for the $name part (first argument of $document->setMetadata))
what results came out with your own tests ?
but if I remove* the
the "htmlspecialchars" from the $document->setMetadata calls in
".../plugins/content/phocaopengraph/phocaopengraph.php"
everything works as expected even when inserting the characters " < > & in the title or desription
*(for the $value part only (second argument of $document->setMetadata)
but not for the $name part (first argument of $document->setMetadata))
what results came out with your own tests ?
- Jan
- Phoca Hero
- Posts: 48736
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: opengraph conten plugin: wrong handling of " (" ")
I get everything OK:


The question is if there is no other process which can somehow influence it.
Jan


The question is if there is no other process which can somehow influence it.

Jan
If you find Phoca extensions useful, please support the project