summaryrefslogtreecommitdiff
path: root/ext/standard/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r--ext/standard/url.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c
index d1d6496565..ab12801d30 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -253,7 +253,8 @@ char *php_url_encode(char *s, int len)
str[y] = hexchars[(unsigned char) s[x] & 15];
}
#else /*CHARSET_EBCDIC*/
- } else if (!isalnum(str[y]) && strchr("_-.", str[y]) != NULL) {
+ } else if (!isalnum(str[y]) && strchr("_-.", str[y]) == NULL) {
+ /* Allow only alphanumeric chars and '_', '-', '.'; escape the rest */
str[y++] = '%';
str[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4];
str[y] = hexchars[os_toascii[(unsigned char) s[x]] & 0x0F];