[wwwsearch-commits] r43607 - wwwsearch/ClientForm/trunk

jjlee at codespeak.net jjlee at codespeak.net
Thu May 24 22:29:42 CEST 2007


Author: jjlee
Date: Thu May 24 22:29:42 2007
New Revision: 43607

Modified:
   wwwsearch/ClientForm/trunk/ClientForm.py
   wwwsearch/ClientForm/trunk/test.py
Log:
Fix ParseError affecting global SELECT and TEXTAREA controls

Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py	(original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py	Thu May 24 22:29:42 2007
@@ -31,7 +31,6 @@
     return hex(struct.unpack('I', struct.pack('i', id(x)))[0]).lower().strip("l")
 
 # XXX
-# SELECT outside of FORM loses last OPTION
 # add an __all__
 # Remove parser testing hack
 # safeUrl()-ize action
@@ -547,8 +546,6 @@
 
     def end_select(self):
         debug("")
-        if self._current_form is self._global_form:
-            return
         if self._select is None:
             raise ParseError("end of SELECT before start")
 
@@ -628,8 +625,6 @@
 
     def end_textarea(self):
         debug("")
-        if self._current_form is self._global_form:
-            return
         if self._textarea is None:
             raise ParseError("end of TEXTAREA before start")
         controls = self._current_form[2]

Modified: wwwsearch/ClientForm/trunk/test.py
==============================================================================
--- wwwsearch/ClientForm/trunk/test.py	(original)
+++ wwwsearch/ClientForm/trunk/test.py	Thu May 24 22:29:42 2007
@@ -758,8 +758,6 @@
         ctl = forms[0].find_control(type="textarea")
         self.assertEqual(ctl.value, "\r\nblah\r\n")
 
-## # XXXX missing form elem --> complains about nested selects! (global form trouble?)
-
     def test_double_select(self):
         # More than one SELECT control of the same name in a form never
         # represent a single control (unlike RADIO and CHECKBOX elements), so
@@ -787,6 +785,32 @@
         ctl = form.find_control(name="a", nr=1)
         self.assertEqual([item.name for item in ctl.items], ["d", "e"])
 
+    def test_global_select(self):
+        # regression test: closing select and textarea tags should not be
+        # ignored, causing a ParseError due to incorrect tag nesting
+
+        forms = ClientForm.ParseFileEx(
+            StringIO("""\
+<select name="a">
+    <option>b</option>
+    <option>c</option>
+</select>
+<select name="a">
+    <option>d</option>
+    <option>e</option>
+</select>
+"""),
+            "http://example.com/",
+            )
+
+        forms = ClientForm.ParseFile(
+            StringIO("""\
+<textarea></textarea>
+<textarea></textarea>
+"""),
+            "http://example.com/",
+            backwards_compat=False,
+            )
 
 
 class DisabledTests(TestCase):


More information about the wwwsearch-commits mailing list