summaryrefslogtreecommitdiff
path: root/ext/mbstring/mbstring.c
diff options
context:
space:
mode:
authorMasaki Kagaya <masakielastic@gmail.com>2015-02-19 15:13:17 +0900
committerMasaki Kagaya <masakielastic@gmail.com>2015-02-19 15:13:17 +0900
commita0890c7c59674623fdf4422fd2b6fa74090e9c8a (patch)
tree43e353d02ac906af4ea7573ad4d30d69e37cea4c /ext/mbstring/mbstring.c
parentb9b47c84a0d637c3a9b4d4e828b38361c1ba834e (diff)
downloadphp-git-a0890c7c59674623fdf4422fd2b6fa74090e9c8a.tar.gz
added php_mb_check_forbidden_encoding
Diffstat (limited to 'ext/mbstring/mbstring.c')
-rw-r--r--ext/mbstring/mbstring.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 55dc1d6931..6e68731562 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -4591,6 +4591,39 @@ PHP_FUNCTION(mb_check_encoding)
}
/* }}} */
+static inline zend_bool php_mb_check_forbidden_encoding(enum mbfl_no_encoding no_enc)
+{
+ if (no_enc == mbfl_no_encoding_pass
+ || no_enc == mbfl_no_encoding_auto
+ || no_enc == mbfl_no_encoding_wchar
+ || no_enc == mbfl_no_encoding_byte2be
+ || no_enc == mbfl_no_encoding_byte2le
+ || no_enc == mbfl_no_encoding_byte4be
+ || no_enc == mbfl_no_encoding_byte4le
+ || no_enc == mbfl_no_encoding_base64
+ || no_enc == mbfl_no_encoding_uuencode
+ || no_enc == mbfl_no_encoding_html_ent
+ || no_enc == mbfl_no_encoding_qprint
+ || no_enc == mbfl_no_encoding_utf7
+ || no_enc == mbfl_no_encoding_utf7imap
+ || no_enc == mbfl_no_encoding_2022kr
+ || no_enc == mbfl_no_encoding_jis
+ || no_enc == mbfl_no_encoding_2022jp
+ || no_enc == mbfl_no_encoding_2022jpms
+ || no_enc == mbfl_no_encoding_jis_ms
+ || no_enc == mbfl_no_encoding_2022jp_2004
+ || no_enc == mbfl_no_encoding_2022jp_kddi
+ || no_enc == mbfl_no_encoding_cp50220
+ || no_enc == mbfl_no_encoding_cp50220raw
+ || no_enc == mbfl_no_encoding_cp50221
+ || no_enc == mbfl_no_encoding_cp50222
+ ) {
+ return true;
+ }
+
+ return false;
+}
+
static inline long php_mb_ord(const char* str, size_t str_len, const char* enc)
{
enum mbfl_no_encoding no_enc;
@@ -4641,31 +4674,7 @@ static inline long php_mb_ord(const char* str, size_t str_len, const char* enc)
(unsigned char) ret[2] << 8 |
(unsigned char) ret[3];
- } else if (no_enc == mbfl_no_encoding_pass
- || no_enc == mbfl_no_encoding_auto
- || no_enc == mbfl_no_encoding_wchar
- || no_enc == mbfl_no_encoding_byte2be
- || no_enc == mbfl_no_encoding_byte2le
- || no_enc == mbfl_no_encoding_byte4be
- || no_enc == mbfl_no_encoding_byte4le
- || no_enc == mbfl_no_encoding_base64
- || no_enc == mbfl_no_encoding_uuencode
- || no_enc == mbfl_no_encoding_html_ent
- || no_enc == mbfl_no_encoding_qprint
- || no_enc == mbfl_no_encoding_utf7
- || no_enc == mbfl_no_encoding_utf7imap
- || no_enc == mbfl_no_encoding_2022kr
- || no_enc == mbfl_no_encoding_jis
- || no_enc == mbfl_no_encoding_2022jp
- || no_enc == mbfl_no_encoding_2022jpms
- || no_enc == mbfl_no_encoding_jis_ms
- || no_enc == mbfl_no_encoding_2022jp_2004
- || no_enc == mbfl_no_encoding_2022jp_kddi
- || no_enc == mbfl_no_encoding_cp50220
- || no_enc == mbfl_no_encoding_cp50220raw
- || no_enc == mbfl_no_encoding_cp50221
- || no_enc == mbfl_no_encoding_cp50222
- ) {
+ } else if (php_mb_check_forbidden_encoding(no_enc)) {
php_error_docref(NULL, E_WARNING, "Unsupported encoding \"%s\"", enc);
return -1;
}