- Posts: 1
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- System plugin shouldn't modify <html> tag on /adminstrator
System plugin shouldn't modify <html> tag on /adminstrator
- Casper Voogt
-
Topic Author
- Offline
- New Member
Less
More
9 years 11 months ago - 9 years 11 months ago #143657
by Casper Voogt
System plugin shouldn't modify <html> tag on /adminstrator was created by Casper Voogt
We just upgraded our CiviCRM to 4.6.2 and were then unable to use its Mailing feature. I traced this down to a syntax error in the HTML code produced by Joomla/K2, specifically "function onAfterRender()" in /plugins/system/k2.php. The relevant section of code was:
The problem in our case was that 'prefix="og: ogp.me......' was being passed into a CiviCRM JavaScript variable verbatim without escaping the quotes, even though other HTML elements with quotes do get escaped properly by CiviCRM. Seems that K2 alters the HTML output at a later stage than when CiviCRM grabs the HTML output - something along those lines. I could have probably solved this in CiviCRM's code too, but felt it made sense to do this in the K2 plugin, because why would we want OpenGraph HTML code in our admin area?
So, I changed this to:
Basically, the above checks whether we're on the public side, and only runs if we are. This resolves the issue for me, though I could imagine this might not even be sufficient in some other situations where there might be a frontend conflict, but I do think this is at least an improvement.
if (JString::strpos($response, 'prefix="og: http://ogp.me/ns#"') === false)
{
$searches[] = '<html ';
$searches[] = '<html>';
$replacements[] = '<html prefix="og: http://ogp.me/ns#" ';
$replacements[] = '<html prefix="og: http://ogp.me/ns#">';
}
The problem in our case was that 'prefix="og: ogp.me......' was being passed into a CiviCRM JavaScript variable verbatim without escaping the quotes, even though other HTML elements with quotes do get escaped properly by CiviCRM. Seems that K2 alters the HTML output at a later stage than when CiviCRM grabs the HTML output - something along those lines. I could have probably solved this in CiviCRM's code too, but felt it made sense to do this in the K2 plugin, because why would we want OpenGraph HTML code in our admin area?
So, I changed this to:
$app =& JFactory::getApplication();
if ($app->isSite()){
if (JString::strpos($response, 'prefix="og: http://ogp.me/ns#"') === false)
{
$searches[] = '<html ';
$searches[] = '<html>';
$replacements[] = '<html prefix="og: http://ogp.me/ns#" ';
$replacements[] = '<html prefix="og: http://ogp.me/ns#">';
}
}
Basically, the above checks whether we're on the public side, and only runs if we are. This resolves the issue for me, though I could imagine this might not even be sufficient in some other situations where there might be a frontend conflict, but I do think this is at least an improvement.
Last edit: 9 years 11 months ago by Casper Voogt. Reason: notify of replies
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Moderator
Less
More
- Posts: 8743
9 years 10 months ago #143735
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic System plugin shouldn't modify <html> tag on /adminstrator
Hi,
I just applied the fix : github.com/joomlaworks/k2/commit/f5cea21896647bf5be0cbe7ee9498272f298b27c .
Thank you for reporting.
I just applied the fix : github.com/joomlaworks/k2/commit/f5cea21896647bf5be0cbe7ee9498272f298b27c .
Thank you for reporting.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Jeremy Nicholls
-
- Offline
- New Member
Less
More
- Posts: 1
9 years 8 months ago #146137
by Jeremy Nicholls
Replied by Jeremy Nicholls on topic System plugin shouldn't modify <html> tag on /adminstrator
Caspar, thanks for finding this! I had the same problem, but in a different part of CiviCRM, and never thought of checking K2.
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- System plugin shouldn't modify <html> tag on /adminstrator