Permalink
Browse files

ignore -> replace. This fixes #28

  • Loading branch information...
1 parent 7024c3f commit 9c9849e9b33704bca44379593ed74f08239d299b @mitsuhiko mitsuhiko committed Jul 5, 2011
Showing with 15 additions and 13 deletions.
  1. +2 −0 CHANGES
  2. +1 −1 werkzeug/_internal.py
  3. +1 −1 werkzeug/contrib/securecookie.py
  4. +2 −2 werkzeug/formparser.py
  5. +1 −1 werkzeug/routing.py
  6. +5 −5 werkzeug/urls.py
  7. +1 −1 werkzeug/utils.py
  8. +2 −2 werkzeug/wrappers.py
View
@@ -73,6 +73,8 @@ Version 0.7
a drop-in replacement.
- added cookie forging support to the test client.
- added support for host based matching in the routing system.
+- switched from the default 'ignore' to the better 'replace'
+ unicode error handling mode.
Version 0.6.2
-------------
View
@@ -204,7 +204,7 @@ def _decode_unicode(value, charset, errors):
return value.decode(charset, errors)
except UnicodeError, e:
if fallback is not None:
- return value.decode(fallback, 'ignore')
+ return value.decode(fallback, 'replace')
from werkzeug.exceptions import HTTPUnicodeError
raise HTTPUnicodeError(str(e))
@@ -261,7 +261,7 @@ def unserialize(cls, string, secret_key):
:return: a new :class:`SecureCookie`.
"""
if isinstance(string, unicode):
- string = string.encode('utf-8', 'ignore')
+ string = string.encode('utf-8', 'replace')
try:
base64_hash, data = string.split('?', 1)
except (ValueError, IndexError):
View
@@ -42,7 +42,7 @@ def default_stream_factory(total_content_length, filename, content_type,
def parse_form_data(environ, stream_factory=None, charset='utf-8',
- errors='ignore', max_form_memory_size=None,
+ errors='replace', max_form_memory_size=None,
max_content_length=None, cls=None,
silent=True):
"""Parse the form data in the environ and return it as tuple in the form
@@ -169,7 +169,7 @@ def is_valid_multipart_boundary(boundary):
def parse_multipart(file, boundary, content_length, stream_factory=None,
- charset='utf-8', errors='ignore', buffer_size=10 * 1024,
+ charset='utf-8', errors='replace', buffer_size=10 * 1024,
max_form_memory_size=None):
"""Parse a multipart/form-data stream. This is invoked by
:func:`utils.parse_form_data` if the content type matches. Currently it
View
@@ -1019,7 +1019,7 @@ class Map(object):
def __init__(self, rules=None, default_subdomain='', charset='utf-8',
strict_slashes=True, redirect_defaults=True,
converters=None, sort_parameters=False, sort_key=None,
- encoding_errors='ignore', host_matching=False):
+ encoding_errors='replace', host_matching=False):
self._rules = []
self._rules_by_endpoint = {}
self._remap = True
View
@@ -148,7 +148,7 @@ def iri_to_uri(iri, charset='utf-8'):
return str(urlparse.urlunsplit([scheme, hostname, path, query, fragment]))
-def uri_to_iri(uri, charset='utf-8', errors='ignore'):
+def uri_to_iri(uri, charset='utf-8', errors='replace'):
r"""Converts a URI in a given charset to a IRI.
Examples for URI versus IRI
@@ -205,7 +205,7 @@ def uri_to_iri(uri, charset='utf-8', errors='ignore'):
def url_decode(s, charset='utf-8', decode_keys=False, include_empty=True,
- errors='ignore', separator='&', cls=None):
+ errors='replace', separator='&', cls=None):
"""Parse a querystring and return it as :class:`MultiDict`. Per default
only values are decoded into unicode strings. If `decode_keys` is set to
`True` the same will happen for keys.
@@ -323,7 +323,7 @@ def url_quote_plus(s, charset='utf-8', safe=''):
return _quote_plus(s, safe=safe)
-def url_unquote(s, charset='utf-8', errors='ignore'):
+def url_unquote(s, charset='utf-8', errors='replace'):
"""URL decode a single string with a given decoding.
Per default encoding errors are ignored. If you want a different behavior
@@ -339,7 +339,7 @@ def url_unquote(s, charset='utf-8', errors='ignore'):
return _decode_unicode(_unquote(s), charset, errors)
-def url_unquote_plus(s, charset='utf-8', errors='ignore'):
+def url_unquote_plus(s, charset='utf-8', errors='replace'):
"""URL decode a single string with the given decoding and decode
a "+" to whitespace.
@@ -370,7 +370,7 @@ def url_fix(s, charset='utf-8'):
unicode string.
"""
if isinstance(s, unicode):
- s = s.encode(charset, 'ignore')
+ s = s.encode(charset, 'replace')
scheme, netloc, path, qs, anchor = _safe_urlsplit(s)
path = _quote(path, '/%')
qs = _quote_plus(qs, ':&%=')
View
@@ -341,7 +341,7 @@ def handle_match(m):
return _entity_re.sub(handle_match, s)
-def parse_cookie(header, charset='utf-8', errors='ignore',
+def parse_cookie(header, charset='utf-8', errors='replace',
cls=None):
"""Parse a cookie. Either from a string or WSGI environ.
View
@@ -113,8 +113,8 @@ class Request(BaseRequest, ETagRequestMixin):
#: the charset for the request, defaults to utf-8
charset = 'utf-8'
- #: the error handling procedure for errors, defaults to 'ignore'
- encoding_errors = 'ignore'
+ #: the error handling procedure for errors, defaults to 'replace'
+ encoding_errors = 'replace'
#: the maximum content length. This is forwarded to the form data
#: parsing function (:func:`parse_form_data`). When set and the

0 comments on commit 9c9849e

Please sign in to comment.