You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2025/12/01 12:03:12 UTC
svn commit: r1930163 - httpd/httpd/trunk/server
Author: covener
Date: Mon Dec 1 12:03:12 2025
New Revision: 1930163
Log:
envvars from HTTP headers low precedence
Modified:
httpd/httpd/trunk/server/util_script.c
Modified: httpd/httpd/trunk/server/util_script.c
==============================================================================
--- httpd/httpd/trunk/server/util_script.c Mon Dec 1 12:01:44 2025 (r1930162)
+++ httpd/httpd/trunk/server/util_script.c Mon Dec 1 12:03:12 2025 (r1930163)
@@ -126,6 +126,8 @@ AP_DECLARE(char **) ap_create_environmen
}
}
for (i = 0; i < env_arr->nelts; ++i) {
+ int changed = 0;
+
if (!elts[i].key) {
continue;
}
@@ -133,18 +135,36 @@ AP_DECLARE(char **) ap_create_environmen
whack = env[j];
if (apr_isdigit(*whack)) {
*whack++ = '_';
+ changed = 1;
}
while (*whack != '=') {
#ifdef WIN32
- if (!apr_isalnum(*whack) && *whack != '(' && *whack != ')') {
+ if (!apr_isalnum(*whack) && *whack != '_' && *whack != '(' && *whack != ')') {
#else
- if (!apr_isalnum(*whack)) {
+ if (!apr_isalnum(*whack) && *whack != '_') {
#endif
*whack = '_';
+ changed = 1;
}
++whack;
}
- ++j;
+ if (changed) {
+ *whack = '\0';
+ /*
+ * If after cleaning up the key the key is identical to an existing key
+ * in the table drop this environment variable. This also prevents
+ * to override CGI reserved environment variables with variables whose
+ * names have an invalid character instead of '_', but are otherwise
+ * equal to the names CGI reserved environment variables.
+ */
+ if (!apr_table_get(t, env[j])) {
+ ++j;
+ *whack = '=';
+ }
+ }
+ else {
+ ++j;
+ }
}
env[j] = NULL;