summaryrefslogtreecommitdiff
path: root/paste/wsgiwrappers.py
diff options
context:
space:
mode:
Diffstat (limited to 'paste/wsgiwrappers.py')
-rw-r--r--paste/wsgiwrappers.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py
index a4b68de..51e556e 100644
--- a/paste/wsgiwrappers.py
+++ b/paste/wsgiwrappers.py
@@ -20,7 +20,7 @@ from paste.util.mimeparse import desired_matches
__all__ = ['WSGIRequest', 'WSGIResponse']
-_CHARSET_RE = re.compile(r'.*;\s*charset=(.*?)(;|$)', re.I)
+_CHARSET_RE = re.compile(r';\s*charset=([^;]*)', re.I)
class DeprecatedSettings(StackedObjectProxy):
def _push_object(self, obj):
@@ -257,7 +257,7 @@ class WSGIRequest(object):
Determine the encoding as specified by the browser via the
Content-Type's charset parameter, if one is set
"""
- charset_match = _CHARSET_RE.match(self.headers.get('Content-Type', ''))
+ charset_match = _CHARSET_RE.search(self.headers.get('Content-Type', ''))
if charset_match:
return charset_match.group(1)
@@ -364,7 +364,7 @@ class WSGIResponse(object):
Determine the encoding as specified by the Content-Type's charset
parameter, if one is set
"""
- charset_match = _CHARSET_RE.match(self.headers.get('Content-Type', ''))
+ charset_match = _CHARSET_RE.search(self.headers.get('Content-Type', ''))
if charset_match:
return charset_match.group(1)
@@ -481,7 +481,7 @@ class WSGIResponse(object):
header = self.headers.pop('content-type')
except KeyError:
raise AttributeError(
- "You cannot set the charset when on content-type is defined")
+ "You cannot set the charset when no content-type is defined")
match = _CHARSET_RE.search(header)
if match:
header = header[:match.start()] + header[match.end():]