[pmwiki-users] Old line-breaks bug still around

The Editor editor at fast.st
Thu Sep 21 20:30:38 CDT 2006


It occurred to me this bug might be somehow connected to the textarea
markup I'm now using, as I don't remember it doing it before.  But in
checking, I noticed it does the same thing whether I use Pm's textarea
markup or my own. So the problem must be in the WritePage function...
Could there be a bug there?

Cheers,
Caveman


[-snip-]

> When I enter text into a textarea with line breaks and save that
> variable using WritePage it results in linebreaks in the actual
> pagecode (so text=... is not all on one line).  Very bad.

>
> // Here's snippets of the function called when the form is submitted
>
> function Data() {
>         global $WorkDir, $data, $log;
>         $nocode = array('"', "'", '\n');
>         $encode = array('"', ''', '%0a');
>         foreach ($_POST as $field => $value) {
>
> // various functions based on fields go here...  The one below saves
> specified fields as
> // field="value" pairs.  If one of those fields is a textarea, with
> line returns it messes up.
> // Note the string replacement
>
>                 if (substr($field, 0, 8) == "savedata") {
>                         $data = "";
>                         $d = explode(",", $value);
>                         foreach ($d as $f => $v) {
>                                 $vv = str_replace($nocode, $encode, $_POST[$v]);
>                                 $data .= "$v=\"$vv\" \n\n";
>                                 }
>                         SetPage($datapage);
>                         }
>
> // Here is the SetPage function which writes the page.  All saved
> fields are compressed
> // into one long string called $data.  Note: I'm using WritePage which
> should fix linebreaks.
>
> function SetPage($d) {
>         global $WorkDir, $data, $log;
>         $contents = "(:comment data:) \n\n$data(:comment data:) \n\n[[#Log]]
> \n\n$log(:comment data:) \n\n";
>         $page['text'] = $contents;
>         Lock(2);
>         WritePage($d, $page);
>         Lock(0);
>         return;
> }
>
> The solution has to be somewhere in these lines because they are all
> that take the input values from the textarea to the wiki page.  Help?
>




More information about the pmwiki-users mailing list