From: Moriyoshi Koizumi Date: Tue, 2 Dec 2003 07:36:42 +0000 (+0000) Subject: all '_' (underscores) should be replaced by '\x20' (whitespaces) X-Git-Tag: php-5.0.0b3RC1~426 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c02eb1ffe031d74f1792477979b787a46486636;p=php all '_' (underscores) should be replaced by '\x20' (whitespaces) in encoding. # should I bump API version? --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index ed236ffc2e..d939e8ecd6 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1478,7 +1478,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st break; case PHP_ICONV_ENC_SCHEME_QPRINT: - decoded_text = (char *)php_quot_print_decode((unsigned char*)encoded_text, (int)encoded_text_len, &decoded_text_len); + decoded_text = (char *)php_quot_print_decode((unsigned char*)encoded_text, (int)encoded_text_len, &decoded_text_len, 1); break; } diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 7c711655a7..3498006c57 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -50,7 +50,7 @@ static char php_hex2int(int c) } } -PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length) +PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length, int replace_us_by_ws) { register unsigned int i; register unsigned const char *p1; @@ -79,6 +79,10 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }; + if (replace_us_by_ws) { + replace_us_by_ws = '_'; + } + i = length, p1 = str; buf_size = length; while (i > 1 && *p1 != '\0') { @@ -127,7 +131,7 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len return NULL; } } else { - *(p2++) = *p1; + *(p2++) = (replace_us_by_ws == *p1 ? '\x20': *p1); i--, p1++, decoded_len++; } } diff --git a/ext/standard/quot_print.h b/ext/standard/quot_print.h index 8588366249..dff3a0cac5 100644 --- a/ext/standard/quot_print.h +++ b/ext/standard/quot_print.h @@ -21,7 +21,7 @@ #ifndef QUOT_PRINT_H #define QUOT_PRINT_H -PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length); +PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length, int replace_us_by_ws); PHP_FUNCTION(quoted_printable_decode);