summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2003-12-02 07:36:42 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2003-12-02 07:36:42 +0000
commit3c02eb1ffe031d74f1792477979b787a46486636 (patch)
treee8e535e6573d8fa9d1235e4cf550839d677c1232
parente9f7e144608df36473490a5bd4b40c54bad83f0f (diff)
downloadphp-git-3c02eb1ffe031d74f1792477979b787a46486636.tar.gz
all '_' (underscores) should be replaced by '\x20' (whitespaces)
in encoding. # should I bump API version?
-rw-r--r--ext/iconv/iconv.c2
-rw-r--r--ext/standard/quot_print.c8
-rw-r--r--ext/standard/quot_print.h2
3 files changed, 8 insertions, 4 deletions
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);