changeset 3815:dcd932f8c4ec

fix MoinMoinBugs/TypeErrorInWikiutils
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 03 Jul 2008 15:24:35 +0200
parents 26240254340b
children 6e7ab559c67d df0218925ef8
files MoinMoin/_tests/test_wikiutil.py MoinMoin/wikiutil.py
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Wed Jul 02 14:47:41 2008 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Thu Jul 03 15:24:35 2008 +0200
@@ -297,6 +297,21 @@
             for val in result[2]:
                 assert val is None or isinstance(val, unicode)
 
+    def testDoubleNameValueSeparator(self):
+        tests = [
+                  # regular and quoting tests
+                  (u'd==4,=3 ',    ([], {u'd': u'=4', u'': u'3'}, [])),
+                  (u'===a,b,c,d',  ([], {u'': u'==a'}, [u'b', u'c', u'd'])),
+                  (u'a,b,===,c,d', ([u'a', u'b'], {u'': u'=='}, [u'c', u'd'])),
+                ]
+
+        def _check(a, e):
+            r = wikiutil.parse_quoted_separated(a)
+            assert r == e
+
+        for args, expected in tests:
+            yield _check, args, expected
+
     def testNoNameValue(self):
         abcd = [u'a', u'b', u'c', u'd']
         tests = [
--- a/MoinMoin/wikiutil.py	Wed Jul 02 14:47:41 2008 +0200
+++ b/MoinMoin/wikiutil.py	Thu Jul 03 15:24:35 2008 +0200
@@ -1424,6 +1424,8 @@
                 cur.append(None)
             else:
                 if not multikey:
+                    if cur[-1] is None:
+                        cur[-1] = ''
                     cur[-1] += name_value_separator
                 else:
                     cur.append(None)