- Posts: 24
- Thank you received: 0
mprestriction plugin issue & fix suggestion
- RC Cola
-
Topic Author
- Offline
- Junior Member
-
Less
More
10 years 1 month ago #59215
by RC Cola
mprestriction plugin issue & fix suggestion was created 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
into
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
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';
Code:
$regex = '#{mprestriction ids=(.*?)}(.*?){/mprestriction}#s';
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.
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.