# HG changeset patch # User paulb # Date 1169339526 0 # Node ID 8c1577cfd19b88ec76d354a71b89754bb9843228 # Parent aafeae51da2b289efd142cb36ceb476c6e215471 [project @ 2007-01-21 00:32:06 by paulb] Added better observance of the default charset. diff -r aafeae51da2b -r 8c1577cfd19b WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ BaseHTTPRequestHandler classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -282,6 +282,8 @@ # NOTE: Support at best ISO-8859-1 values. + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/CGI.py --- a/WebStack/CGI.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/CGI.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ CGI classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -220,6 +220,8 @@ character values. """ + encoding = encoding or self.default_charset + path = decode_value(self.env.get("SCRIPT_NAME") or "", encoding) path += self.get_path_info(encoding) return path @@ -237,6 +239,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value(self.env.get("PATH_INFO") or "", encoding) def get_query_string(self): @@ -262,6 +266,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/Django.py --- a/WebStack/Django.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/Django.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ Django classes. -Copyright (C) 2006 Paul Boddie +Copyright (C) 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -167,6 +167,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value(self.request.get_full_path(), encoding) def get_path_without_query(self, encoding=None): @@ -197,6 +199,8 @@ character values. """ + encoding = encoding or self.default_charset + path_info = self.request.META.get("PATH_INFO") or "" return decode_value(path_info, encoding) @@ -246,6 +250,9 @@ return fields def _get_fields(self, source, encoding=None): + + encoding = encoding or self.get_content_type().charset or self.default_charset + fields = {} for name in source.keys(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/ModPython.py --- a/WebStack/ModPython.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/ModPython.py Sun Jan 21 00:32:06 2007 +0000 @@ -183,6 +183,8 @@ character values. """ + encoding = encoding or self.default_charset + query_string = self.get_query_string() if query_string: return decode_value(self.trans.uri, encoding) + "?" + query_string @@ -201,6 +203,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value(self.trans.uri, encoding) def get_path_info(self, encoding=None): @@ -216,6 +220,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value(self.trans.path_info, encoding) def get_query_string(self): @@ -241,6 +247,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), 1).items(): # keep_blank_values=1 name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/Twisted.py --- a/WebStack/Twisted.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/Twisted.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ Twisted classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -185,6 +185,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value("/%s" % "/".join(self.trans.postpath), encoding) def get_query_string(self): @@ -217,6 +219,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/WSGI.py --- a/WebStack/WSGI.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/WSGI.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ WSGI classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -222,6 +222,8 @@ character values. """ + encoding = encoding or self.default_charset + path = decode_value(self.env.get("SCRIPT_NAME") or "", encoding) path += self.get_path_info(encoding) return path @@ -239,6 +241,8 @@ character values. """ + encoding = encoding or self.default_charset + return decode_value(self.env.get("PATH_INFO") or "", encoding) def get_query_string(self): @@ -264,6 +268,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/Webware.py --- a/WebStack/Webware.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/Webware.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ Webware classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -195,6 +195,8 @@ character values. """ + encoding = encoding or self.default_charset + path_info = self.trans.request().pathInfo() context_name = self.trans.request().contextName() if path_info.startswith(context_name): @@ -226,6 +228,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): name = decode_value(name, encoding) diff -r aafeae51da2b -r 8c1577cfd19b WebStack/Zope.py --- a/WebStack/Zope.py Sat Jan 20 23:16:25 2007 +0000 +++ b/WebStack/Zope.py Sun Jan 21 00:32:06 2007 +0000 @@ -3,7 +3,7 @@ """ Zope classes. -Copyright (C) 2004, 2005, 2006 Paul Boddie +Copyright (C) 2004, 2005, 2006, 2007 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -180,6 +180,8 @@ # NOTE: Based on WebStack.CGI.get_path. + encoding = encoding or self.default_charset + path = decode_value(self.request.environ.get("SCRIPT_NAME") or "", encoding) path += self.get_path_info(encoding) return path @@ -197,6 +199,8 @@ character values. """ + encoding = encoding or self.default_charset + product_path = "/".join(self.adapter.getPhysicalPath()) path_info = self.request.environ.get("PATH_INFO") or "" real_path_info = path_info[len(product_path):] @@ -225,6 +229,8 @@ single value is associated with any given field name). """ + encoding = encoding or self.default_charset + fields = {} for name, values in cgi.parse_qs(self.get_query_string()).items(): name = decode_value(name, encoding)