Commits

Mike Orr committed 59054a8

Urlencode ``urlify()`` return value in case it contains "?".

  • Participants
  • Parent commits 82b961b

Comments (0)

Files changed (3)

   - Preserve case of "method" arg in ``button_to()`` for XHTML compatibility. 
     Patch by transducer.
 
+* webhelpers.text:
+
+  - Urlencode ``urlify()`` return value in case it contains special
+    characters like "?". Reported by mcd34@gmail.com.
+
 1.1 (2010-08-09)
 ----------------
 

File tests/test_text.py

         eq_(control, strip_leading_whitespace(s))
 
     # @@MO wrap_paragraphs untested.
+
+    def test_urlify(self):
+        s = "What is this? It is a car."
+        control = "What%20is%20this%3f%20It%20is%20a%20car."

File webhelpers/text.py

 
 import re
 import textwrap
+import urllib
 
 from webhelpers.html.tools import strip_tags
 
 
     Based on Ruby's stringex package
     (http://github.com/rsl/stringex/tree/master)
+
+    Changed in WebHelpers 1.2: urlecode the result in case it contains special
+    characters like "?". 
     """
     s = remove_formatting(string).lower()
     s = replace_whitespace(s, '-')
-    return collapse(s, '-')
+    s = collapse(s, '-')
+    return urllib.quote(s)
 
 
 def remove_formatting(string):