mprestriction plugin issue & fix suggestion

  • RC Cola
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 1 month ago #59215 by RC Cola
Hi all,

I found some strange behavior with the mprestriction plugin that I wanted to share.

The mprestriction plugin relies on two blocks of text {mprestriction ids="x,y,z"} ... ... {/mprestriction} to work properly, but the regex that the plugin uses can be stepped on by some Joomla editors (JoomlaCK, for example) when these editors 'clean' the article text before saving.

The problem is that some editors translate the quotation marks ( " and ") into the text string '"' instead of the actual quotation marks. Without these quotation marks, the regular expression search for the mprestriction plugin fails, and nothing happens.

This can be a real pain because the text all looks OK to the Joomla Admin, but the problem can only be found after looking closely at the HTML source.

My suggestion to get around this is to add a new parameter to the plugin which can be the delimiter for the string, or alternatively, change the regex to treat anything after the "ids=" as the numbers. The latter might be a bit easier, changing
Code:
File: plugins/content/mprestriction/mprestriction.php line 21 $regex = '#{mprestriction ids="(.*?)"}(.*?){/mprestriction}#s';
into
Code:
$regex = '#{mprestriction ids=(.*?)}(.*?){/mprestriction}#s';
which would do it, I think. The quotes don't actually make it into the processResrtictions call, so it should be fine.

A short-term workaround for this behavior is to use an editor that doesn't try and clean your text (TinyMCE for example).

Hope this helps

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