[dokuwiki] POST'ed data from xhtml+xml pages.

  • From: Mike Schacht <mschacht@xxxxxxxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 17 May 2008 10:29:33 -0600

I've been using a souped up version of mathmulti and tweaked template pages to get mathml displayed properly in dokuwiki pages. It mostly works perfectly but there are some issues about how POST data is sent that cause some trouble. I would like to know if some simple fixes could be integrated into the distributed code.


The stock inc/form.php includes a line break between the end of the textarea tag and the beginning of the content. This doesn't appear to matter for html pages, but when rendered as xhtml+xml (+mathml) this newline is included in the POST data and is added to the beginning of the block of text to insert. Thus, saving a page add an extra line break to the content and even pressing preview repeatedly will insert an extra line at the head each time. Removing the break from the code that writes it in form.php immediately fixes this. e.g:

diff -r dokuwiki/inc/form.php dokuwiki-2008-05-05/inc/form.php
643c643
<          .buildAttributes($attrs,true).'>'
---
>          .buildAttributes($attrs,true).'>'.NL

I don't know if there are any other consequences.

Similarly, the hidden parameters name="prefix" and "suffix", that are used when editing sections of a larger page lose their line breaks in the POSTed data. Thus everything before and after the edited section get collapsed to a single line each completely screwing up the page. I got around this for the moment by replacing the breaks with a literal "\n" before writing the input tags:

diff -r dokuwiki/inc/html.php dokuwiki-2008-05-05/inc/html.php
1083,1084c1083,1084
<   $form->addHidden('prefix', str_replace("\n","\\n",$PRE));
<   $form->addHidden('suffix', str_replace("\n","\\n",$SUF));
---
>   $form->addHidden('prefix', $PRE);
>   $form->addHidden('suffix', $SUF);

And then breaking those down to proper newlines again before using the data:

diff -r dokuwiki/doku.php dokuwiki-2008-05-05/doku.php
33,34c33,34
<   $PRE   = cleanText(str_replace("\\n","\n",$_POST['prefix']));
<   $SUF   = cleanText(str_replace("\\n","\n",$_POST['suffix']));
---
>   $PRE   = cleanText($_POST['prefix']);
>   $SUF   = cleanText($_POST['suffix']);

obviously this will cause problems if there are intentional sequences of \n in the text.


Mike Schacht
mschacht@xxxxxxxxxxxxxxxxxxxxx



--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts:

  • » [dokuwiki] POST'ed data from xhtml+xml pages.