From: Antony Dovgal Date: Tue, 6 Dec 2005 13:46:56 +0000 (+0000) Subject: don't try to encode empty strings X-Git-Tag: RELEASE_1_0~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b35b72f9ed0ac2caa2ed207bf311f49e59208e82;p=php don't try to encode empty strings --- diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 992d00a303..1c1f4db43e 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -34,6 +34,10 @@ static void php_filter_encode_html(zval *value, char* chars, int encode_nul) int len = Z_STRLEN_P(value); char *s = Z_STRVAL_P(value); + if (Z_STRLEN_P(value) == 0) { + return; + } + for (x = 0, y = 0; len--; x++, y++) { if (strchr(chars, s[x]) || (encode_nul && s[x] == 0)) { smart_str_appendl(&str, "&#", 2); @@ -56,6 +60,10 @@ static void php_filter_encode_html_high_low(zval *value, long flags) int len = Z_STRLEN_P(value); unsigned char *s = Z_STRVAL_P(value); + if (Z_STRLEN_P(value) == 0) { + return; + } + for (x = 0, y = 0; len--; x++, y++) { if (((flags & FILTER_FLAG_ENCODE_LOW) && (s[x] < 32)) || ((flags & FILTER_FLAG_ENCODE_HIGH) && (s[x] > 127))) { smart_str_appendl(&str, "&#", 2); @@ -227,7 +235,7 @@ void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL) void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL) { /* Only if no flags are set (optimization) */ - if (flags != 0) { + if (flags != 0 && Z_STRLEN_P(value) > 0) { php_filter_strip(value, flags); if (flags & FILTER_FLAG_ENCODE_AMP) { php_filter_encode_html(value, "&", 0);