]> granicus.if.org Git - php/commitdiff
all '_' (underscores) should be replaced by '\x20' (whitespaces)
authorMoriyoshi Koizumi <moriyoshi@php.net>
Tue, 2 Dec 2003 07:36:42 +0000 (07:36 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Tue, 2 Dec 2003 07:36:42 +0000 (07:36 +0000)
in encoding.
# should I bump API version?

ext/iconv/iconv.c
ext/standard/quot_print.c
ext/standard/quot_print.h

index ed236ffc2eb832efc76b48579e57303829645c0b..d939e8ecd6c4addf28b11bcd4adaef097657ed17 100644 (file)
@@ -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;
                                                }
 
index 7c711655a72a01bdc538070347c1a92ff5123cea..3498006c5750f502360fd24210449334ffd2ba46 100644 (file)
@@ -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++;
                }
        }
index 858836624947b4eccd57a75e01baaa9cdc8c0629..dff3a0cac59ee836b56c672fa698c9cf0e3f3f40 100644 (file)
@@ -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);