Skip to content
Open
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
16 changes: 4 additions & 12 deletions src/server/mod_wsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2629,14 +2629,10 @@ static PyObject *Adapter_environ(AdapterObject *self)
if (elts[i].val) {
#if PY_MAJOR_VERSION >= 3
if (!strcmp(elts[i].val, "DOCUMENT_ROOT")) {
object = PyUnicode_Decode(elts[i].val, strlen(elts[i].val),
Py_FileSystemDefaultEncoding,
"surrogateescape");
object = PyUnicode_DecodeFSDefault(elts[i].val);
}
else if (!strcmp(elts[i].val, "SCRIPT_FILENAME")) {
object = PyUnicode_Decode(elts[i].val, strlen(elts[i].val),
Py_FileSystemDefaultEncoding,
"surrogateescape");
object = PyUnicode_DecodeFSDefault(elts[i].val);
}
else {
object = PyUnicode_DecodeLatin1(elts[i].val,
Expand Down Expand Up @@ -3858,9 +3854,7 @@ static int wsgi_reload_required(apr_pool_t *pool, request_rec *r,

Py_INCREF(object);
#if PY_MAJOR_VERSION >= 3
path = PyUnicode_Decode(resource, strlen(resource),
Py_FileSystemDefaultEncoding,
"surrogateescape");
path = PyUnicode_DecodeFSDefault(resource);
args = Py_BuildValue("(O)", path);
Py_DECREF(path);
#else
Expand Down Expand Up @@ -14390,9 +14384,7 @@ static PyObject *Auth_environ(AuthObject *self, const char *group)

#if PY_MAJOR_VERSION >= 3
value = ap_document_root(r);
object = PyUnicode_Decode(value, strlen(value),
Py_FileSystemDefaultEncoding,
"surrogateescape");
object = PyUnicode_DecodeFSDefault(value);
#else
object = PyString_FromString(ap_document_root(r));
#endif
Expand Down
39 changes: 8 additions & 31 deletions src/server/wsgi_interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,7 @@ InterpreterObject *newInterpreterObject(const char *name)
if (pwent && getenv("USER")) {
#if PY_MAJOR_VERSION >= 3
key = PyUnicode_FromString("USER");
value = PyUnicode_Decode(pwent->pw_name,
strlen(pwent->pw_name),
Py_FileSystemDefaultEncoding,
"surrogateescape");
value = PyUnicode_DecodeFSDefault(pwent->pw_name);
#else
key = PyString_FromString("USER");
value = PyString_FromString(pwent->pw_name);
Expand All @@ -746,10 +743,7 @@ InterpreterObject *newInterpreterObject(const char *name)
if (pwent && getenv("USERNAME")) {
#if PY_MAJOR_VERSION >= 3
key = PyUnicode_FromString("USERNAME");
value = PyUnicode_Decode(pwent->pw_name,
strlen(pwent->pw_name),
Py_FileSystemDefaultEncoding,
"surrogateescape");
value = PyUnicode_DecodeFSDefault(pwent->pw_name);
#else
key = PyString_FromString("USERNAME");
value = PyString_FromString(pwent->pw_name);
Expand All @@ -764,10 +758,7 @@ InterpreterObject *newInterpreterObject(const char *name)
if (pwent && getenv("LOGNAME")) {
#if PY_MAJOR_VERSION >= 3
key = PyUnicode_FromString("LOGNAME");
value = PyUnicode_Decode(pwent->pw_name,
strlen(pwent->pw_name),
Py_FileSystemDefaultEncoding,
"surrogateescape");
value = PyUnicode_DecodeFSDefault(pwent->pw_name);
#else
key = PyString_FromString("LOGNAME");
value = PyString_FromString(pwent->pw_name);
Expand Down Expand Up @@ -816,10 +807,7 @@ InterpreterObject *newInterpreterObject(const char *name)
if (pwent) {
#if PY_MAJOR_VERSION >= 3
key = PyUnicode_FromString("HOME");
value = PyUnicode_Decode(pwent->pw_dir,
strlen(pwent->pw_dir),
Py_FileSystemDefaultEncoding,
"surrogateescape");
value = PyUnicode_DecodeFSDefault(pwent->pw_dir);
#else
key = PyString_FromString("HOME");
value = PyString_FromString(pwent->pw_dir);
Expand Down Expand Up @@ -862,10 +850,7 @@ InterpreterObject *newInterpreterObject(const char *name)
if (object) {
#if PY_MAJOR_VERSION >= 3
key = PyUnicode_FromString("PYTHON_EGG_CACHE");
value = PyUnicode_Decode(wsgi_python_eggs,
strlen(wsgi_python_eggs),
Py_FileSystemDefaultEncoding,
"surrogateescape");
value = PyUnicode_DecodeFSDefault(wsgi_python_eggs);
#else
key = PyString_FromString("PYTHON_EGG_CACHE");
value = PyString_FromString(wsgi_python_eggs);
Expand Down Expand Up @@ -1135,9 +1120,7 @@ InterpreterObject *newInterpreterObject(const char *name)
PyObject *item;

#if PY_MAJOR_VERSION >= 3
item = PyUnicode_Decode(home, strlen(home),
Py_FileSystemDefaultEncoding,
"surrogateescape");
item = PyUnicode_DecodeFSDefault(home);
#else
item = PyString_FromString(home);
#endif
Expand Down Expand Up @@ -1463,20 +1446,14 @@ InterpreterObject *newInterpreterObject(const char *name)
PyObject *result = NULL;

#if PY_MAJOR_VERSION >= 3
config_file = PyUnicode_Decode(wsgi_newrelic_config_file,
strlen(wsgi_newrelic_config_file),
Py_FileSystemDefaultEncoding,
"surrogateescape");
config_file = PyUnicode_DecodeFSDefault(wsgi_newrelic_config_file);
#else
config_file = PyString_FromString(wsgi_newrelic_config_file);
#endif

if (wsgi_newrelic_environment) {
#if PY_MAJOR_VERSION >= 3
environment = PyUnicode_Decode(wsgi_newrelic_environment,
strlen(wsgi_newrelic_environment),
Py_FileSystemDefaultEncoding,
"surrogateescape");
environment = PyUnicode_DecodeFSDefault(wsgi_newrelic_environment);
#else
environment = PyString_FromString(
wsgi_newrelic_environment);
Expand Down