[pmwiki-users] Retain markup expressions inside input and textareas

DaveG pmwiki at solidgone.com
Mon Dec 29 12:58:57 CST 2008



Hans wrote:
> Sunday, December 28, 2008, 4:30:27 AM, Petko Yotov wrote:
> Dave, I don't know if this is of use to you:
> 
> FoxForum (in foxforum.php) uses a custom PTV markup
> (::var:multiline value::) for posting text area content
> including directives as a PTV.
> Defined like this:
> 
> # add new PTV pattern for text PTV (::var:...::)
> $PageTextVarPatterns['(::var:...::)'] =
>     '/(\\(:: *(\\w[-\\w]*) *:(?!\\))\\s?)(.*?)(::\\))/s';
> 
> The PTV pattern (:var:value:) is not unset, to stay useful.
> 
> Security is dealt with within Fox by setting a variable
> $EnablePostDirectives = true;
> If it is false, the default, Fox will "defuse" any directives found in variables
> posted (similar to adding an extra space).
> See also function FoxDefuseItem in fox.php
This was very helpful -- your code is very readable, and combined with 
Petko's code, helped me with the solution.

Turns out that Petko's idea basically worked -- except doing an unset on 
an entire array causes the array to become undeclared, which SDV then 
sees as not there and so sets the usual default values. Setting to an 
empty array worked.

So I combined these approaches with an ROS pattern to get the final 
solution. Needs more testing, but for now seems to work great.
    $PmFormPostPatterns = array();
    Markup('textvar::',
       '<split', '/\\(::\\w[-\\w]*:(?!\\)).*?::\\)/s', '');
    $PageTextVarPatterns['(::var:...::)'] =
       '/(\\(:: *(\\w[-\\w]*) *:(?!\\))\\s?)(.*?)(::\\))/s';
    $ROSPatterns["/\\(:myvar:(.*?)(:\\))$$/si"] =
       "(::myvar:$1::)";  //assumes myvar is the last in the list.


> Hope this helps, nothing more frustrating than to abandon efforts
> after days of work!
Thanks very much for offering suggestions -- I wouldn't have made it 
without them :)

> Happy New Year to all of you!
And to you as well!



More information about the pmwiki-users mailing list