Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for issue #14 #73

Closed
wants to merge 1 commit into from

2 participants

@pjz

Minor changes to make web.py Form validation more self-consistent. Requires that values be strings or unicode natively instead of autoconverting via unicode().

@aaronsw
Owner

Rejecting this patch, per discussion in issue #14.

@aaronsw aaronsw closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 20, 2011
  1. @pjz
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 7 deletions.
  1. +5 −7 web/net.py
View
12 web/net.py
@@ -167,24 +167,22 @@ def htmlunquote(text):
text = text.replace(u"&", u"&") # Must be done last!
return text
-def websafe(val):
+def websafe(val=u''):
r"""Converts `val` so that it is safe for use in Unicode HTML.
>>> websafe("<'&\">")
u'&lt;&#39;&amp;&quot;&gt;'
- >>> websafe(None)
+ >>> websafe()
u''
>>> websafe(u'\u203d')
u'\u203d'
>>> websafe('\xe2\x80\xbd')
u'\u203d'
"""
- if val is None:
- return u''
- elif isinstance(val, str):
+ if isinstance(val, str):
val = val.decode('utf-8')
- elif not isinstance(val, unicode):
- val = unicode(val)
+ if not isinstance(val, unicode):
+ raise ValueError("Cravenly refusing to autoconvert to unicode")
return htmlquote(val)
Something went wrong with that request. Please try again.