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

Petko Yotov 5ko at 5ko.fr
Sat Dec 27 22:30:27 CST 2008


On Sunday 28 December 2008 04:23:09 DaveG wrote:
> DaveG wrote:
> > Docs and code suggest that $PmFormPostPatterns is used as the basis for
> > text replacement in PmForms. However, setting in config.php:
> >     $PmFormPostPatterns = array();
> >
> > Causes all text beyond the closing :) to be stripped.
>
> At the risk of talking to myself, it looks like the problem is that form
> variables are stored in the form:
>     (:variable:value:)
>
> Thus, if something is stored containing markup of the form (:markup:)
> the form processor thinks it's got to the markup representing the end of
> the variable value, the :).
>
> Which is pretty frustrating, since I just spent the last three days
> working on a cookbook, thinking I could store any text in a form
> variable. Checking the code, I don't see an easy way to store markup
> type text using pmwiki forms. Is there perhaps some way to capture the
> text using a form, but send the entry to a page for storage; although
> then I'm not sure I could pull the page content back into the entry form
>   using PmForms.
>
> Any ideas?

Allowing users to add (:directives:) may be risky, they could add 
(:noaction:), (:noleft:), (:noheader:), (:notitle:), (:redirect SomeWhere:), 
(:linebreaks:) and other possibly dangerous / defacing markups like (:if 
false:)

If you really want to allow directives with "(:" and ":)" in posts of PmForm, 
you can define another "PTV Pattern", and remove the existing one:

unset($PmFormPostPatterns); # or each one individually
unset($PageTextVarPatterns['(:var:...:)']);
$PageTextVarPatterns['(==var:...==)'] =
  '/(\\(== *(\\w[-\\w]*) *:(?!\\))\\s?)(.*?)(==\\))/s';

Thus, your multiline PageTextVariables will be stored in fields like this:
(==name:value==)

Note that this is a big change in how people use PageTextVariables in their 
pages, so if someone is already using them, they may not want to change all 
in order to use your recipe.

If it is possible to not store page (:directives:) via PmForm, or agree to the 
default behavior that adds a space, your life and the life of the users of 
your recipe will be much easier. 

Also, a wiki writer having that much knowledge of PmWiki (to manipulate page 
directives), he could just use the "edit" link to modify the page, couldn't 
he?

Thanks,
Petko

P.S. If you just need to add content in a page, but not edit it later in 
PmForms, you could possibly add some (:directive:) in your local templates. 
See how the user input is handled at PmForm:Comments and PmfTemplates:
  http://www.pmwiki.org/pmform/PmForm/Comments
  http://www.pmwiki.org/pmform/Site/PmFormTemplates




More information about the pmwiki-users mailing list