Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/python/mod_python/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class StringField(bytes):
disp_options = None

def __new__(self, value):
return bytes.__new__(self, value)
return bytes.__new__(self, value, "utf8")

def __init__(self, value):
self.value = value
Expand Down
10 changes: 6 additions & 4 deletions src/_apachemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ static PyObject *parse_qs(PyObject *self, PyObject *args)
cval = PyBytes_AS_STRING(val);

if (unicode) {
// The query string is supposed to be a valid UTF8 string
// https://url.spec.whatwg.org/#percent-encoded-bytes
PyObject *list, *ukey, *uval;
ukey = PyUnicode_DecodeLatin1(ckey, strlen(ckey), NULL);
uval = PyUnicode_DecodeLatin1(ckey, strlen(cval), NULL);
ukey = PyUnicode_DecodeUTF8(ckey, strlen(ckey), NULL);
uval = PyUnicode_DecodeUTF8(ckey, strlen(cval), NULL);
list = PyDict_GetItem(dict, ukey);
if (list) {
PyList_Append(list, uval);
Expand Down Expand Up @@ -371,8 +373,8 @@ static PyObject *parse_qsl(PyObject *self, PyObject *args)
PyObject *listitem = NULL;
if (unicode) {
PyObject *ukey, *uval;
ukey = PyUnicode_DecodeLatin1(ckey, strlen(ckey), NULL);
uval = PyUnicode_DecodeLatin1(cval, strlen(cval), NULL);
ukey = PyUnicode_DecodeUTF8(ckey, strlen(ckey), NULL);
uval = PyUnicode_DecodeUTF8(cval, strlen(cval), NULL);
listitem = Py_BuildValue("(O,O)", ukey, uval);
Py_DECREF(ukey);
Py_DECREF(uval);
Expand Down