From 56523eec50d8c38d5403ee0c00434ee20725813b Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 19 Dec 2009 16:16:52 +0100
Subject: [PATCH] do not trim XMLRPC values FS#1824

Ignore-this: f43d3f070cfae4040e0e70648d0e541a
The XMLRPC backend will not trim whitespaces or newlines from string values
anymore.

darcs-hash:20091219151652-7ad00-94d6cb26ff6396e09f107cf09dccb5423680c5c9.gz
---
 inc/IXR_Library.php | 3 ++-
 lib/exe/xmlrpc.php  | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php
index 088ae8d45..2752e31f2 100644
--- a/inc/IXR_Library.php
+++ b/inc/IXR_Library.php
@@ -176,6 +176,7 @@ class IXR_Message {
     }
     function tag_open($parser, $tag, $attr) {
         $this->currentTag = $tag;
+        $this->_currentTagContents = '';
         switch($tag) {
             case 'methodCall':
             case 'methodResponse':
@@ -211,7 +212,7 @@ class IXR_Message {
                 $valueFlag = true;
                 break;
             case 'string':
-                $value = (string)trim($this->_currentTagContents);
+                $value = (string)$this->_currentTagContents;
                 $this->_currentTagContents = '';
                 $valueFlag = true;
                 break;
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php
index 9b440c9f5..d3913482f 100644
--- a/lib/exe/xmlrpc.php
+++ b/lib/exe/xmlrpc.php
@@ -466,14 +466,14 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
         global $conf;
 
         $id    = cleanID($id);
-        $TEXT  = trim($text);
+        $TEXT  = cleanText($text);
         $sum   = $params['sum'];
         $minor = $params['minor'];
 
         if(empty($id))
             return new IXR_Error(1, 'Empty page ID');
 
-        if(!page_exists($id) && empty($TEXT)) {
+        if(!page_exists($id) && trim($TEXT) == '' ) {
             return new IXR_ERROR(1, 'Refusing to write an empty new wiki page');
         }
 
-- 
GitLab