[Checkins] SVN: Zope3/branches/3.3/ fix issue 644 in the 3.3 branch by applying revisions 69171 and 69172 from the

Benji York benji at zope.com
Tue Jul 18 14:49:36 EDT 2006


Log message for revision 69192:
  fix issue 644 in the 3.3 branch by applying revisions 69171 and 69172 from the
  trunk
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  U   Zope3/branches/3.3/src/ClientForm.py
  U   Zope3/branches/3.3/src/zope/testbrowser/README.txt
  U   Zope3/branches/3.3/src/zope/testbrowser/tests.py

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-07-18 18:48:46 UTC (rev 69191)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-07-18 18:49:35 UTC (rev 69192)
@@ -10,6 +10,9 @@
 
     Bugfixes
 
+      - Fixed issue 644, ClientForm (part of mechanize) which zope.testbrowser
+        uses didn't handle stripping a new line immediately after a start tag.
+
       - Fixed issue 664, apidoc didn't properly handle attributes that
         showed up in dir() but that weren't gettable.
 

Modified: Zope3/branches/3.3/src/ClientForm.py
===================================================================
--- Zope3/branches/3.3/src/ClientForm.py	2006-07-18 18:48:46 UTC (rev 69191)
+++ Zope3/branches/3.3/src/ClientForm.py	2006-07-18 18:49:35 UTC (rev 69192)
@@ -642,6 +642,13 @@
                 d["__label"] = self._current_label
 
     def handle_data(self, data):
+        # according to http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1
+        # line break immediately after start tags or immediately before end
+        # tags must be ignored, but real browsers only ignore a line break
+        # after a start tag, so we'll do that.
+        if data[0:1] == '\n':
+            data = data[1:]
+
         debug("%s", data)
         if self._option is not None:
             # self._option is a dictionary of the OPTION element's HTML

Modified: Zope3/branches/3.3/src/zope/testbrowser/README.txt
===================================================================
--- Zope3/branches/3.3/src/zope/testbrowser/README.txt	2006-07-18 18:48:46 UTC (rev 69191)
+++ Zope3/branches/3.3/src/zope/testbrowser/README.txt	2006-07-18 18:49:35 UTC (rev 69192)
@@ -621,7 +621,7 @@
     >>> verifyObject(interfaces.IControl, ctrl)
     True
     >>> ctrl.value
-    '\n        Text inside\n        area!\n      '
+    '        Text inside\n        area!\n      '
     >>> ctrl.value = 'A lot of\n text.'
     >>> ctrl.disabled
     False

Modified: Zope3/branches/3.3/src/zope/testbrowser/tests.py
===================================================================
--- Zope3/branches/3.3/src/zope/testbrowser/tests.py	2006-07-18 18:48:46 UTC (rev 69191)
+++ Zope3/branches/3.3/src/zope/testbrowser/tests.py	2006-07-18 18:49:35 UTC (rev 69192)
@@ -218,6 +218,66 @@
 
     """
 
+
+def test_strip_linebreaks_from_textarea(self):
+    """
+
+    >>> browser = Browser()
+
+According to http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1 line break
+immediately after start tags or immediately before end tags must be ignored,
+but real browsers only ignore a line break after a start tag.  So if we give
+the following form:
+
+    >>> browser.open('''
+    ... <html><body>
+    ...   <form action="." method="post" enctype="multipart/form-data">
+    ...      <textarea name="textarea">
+    ... Foo
+    ... </textarea>
+    ...   </form></body></html>
+    ... ''') # doctest: +ELLIPSIS
+    GET / HTTP/1.1
+    ...
+
+The value of the textarea won't contain the first line break:
+
+    >>> browser.getControl(name='textarea').value
+    'Foo\\n'
+
+Of course, if we add line breaks, so that there are now two line breaks
+after the start tag, the textarea value will start and end with a line break.
+
+    >>> browser.open('''
+    ... <html><body>
+    ...   <form action="." method="post" enctype="multipart/form-data">
+    ...      <textarea name="textarea">
+    ...
+    ... Foo
+    ... </textarea>
+    ...   </form></body></html>
+    ... ''') # doctest: +ELLIPSIS
+    GET / HTTP/1.1
+    ...
+
+    >>> browser.getControl(name='textarea').value
+    '\\nFoo\\n'
+
+Also, if there is some other whitespace after the start tag, it will be preserved.
+
+    >>> browser.open('''
+    ... <html><body>
+    ...   <form action="." method="post" enctype="multipart/form-data">
+    ...      <textarea name="textarea">  Foo  </textarea>
+    ...   </form></body></html>
+    ... ''') # doctest: +ELLIPSIS
+    GET / HTTP/1.1
+    ...
+
+    >>> browser.getControl(name='textarea').value
+    '  Foo  '
+    """
+
 checker = renormalizing.RENormalizing([
     (re.compile(r'^--\S+\.\S+\.\S+', re.M), '-'*30),
     (re.compile(r'boundary=\S+\.\S+\.\S+'), 'boundary='+'-'*30),



More information about the Checkins mailing list