Keyword

System plugin shouldn't modify <html> tag on /adminstrator

  • Casper Voogt
  • Casper Voogt's Avatar Topic Author
  • Offline
  • New Member
More
5 years 6 months ago - 5 years 6 months ago #143657 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:
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: 5 years 6 months ago by Casper Voogt. Reason: notify of replies

Please Log in or Create an account to join the conversation.

More
5 years 6 months ago #143735 by Lefteris
Hi,

I just applied the fix : github.com/joomlaworks/k2/commit/f5cea21896647bf5be0cbe7ee9498272f298b27c .

Thank you for reporting.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

Please Log in or Create an account to join the conversation.

More
5 years 4 months ago #146137 by Jeremy Nicholls
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.


Powered by Kunena Forum