diff options
Diffstat (limited to 'ext/xml')
39 files changed, 55 insertions, 144 deletions
diff --git a/ext/xml/compat.c b/ext/xml/compat.c index fbebb635ee..40da824ad8 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/xml/config.w32 b/ext/xml/config.w32 index c0bdfd56ef..4ee0bd1602 100644 --- a/ext/xml/config.w32 +++ b/ext/xml/config.w32 @@ -16,4 +16,4 @@ if (PHP_XML == "yes") { WARNING("xml support can't be enabled, libraries or headers are missing") PHP_ZLIB = "no" } -}
\ No newline at end of file +} diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h index 424785f566..bb6dbdd285 100644 --- a/ext/xml/expat_compat.h +++ b/ext/xml/expat_compat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h index 7766834ea4..568c1a844c 100644 --- a/ext/xml/php_xml.h +++ b/ext/xml/php_xml.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/xml/tests/bug62328.phpt b/ext/xml/tests/bug62328.phpt new file mode 100644 index 0000000000..e4c3c59d37 --- /dev/null +++ b/ext/xml/tests/bug62328.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #62328 (implementing __toString and a cast to string fails) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php +class UberSimpleXML extends SimpleXMLElement { + public function __toString() { + return 'stringification'; + } +} + +$xml = new UberSimpleXML('<xml/>'); + +var_dump((string) $xml); +var_dump($xml->__toString()); +--EXPECT-- +string(15) "stringification" +string(15) "stringification" diff --git a/ext/xml/tests/utf8_decode_variation1.phpt b/ext/xml/tests/utf8_decode_variation1.phpt index 5966531723..4b9679a895 100644 --- a/ext/xml/tests/utf8_decode_variation1.phpt +++ b/ext/xml/tests/utf8_decode_variation1.phpt @@ -79,7 +79,7 @@ $values = array( // loop through each element of the array for data foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( utf8_decode($value) ); }; diff --git a/ext/xml/tests/utf8_encode_variation1.phpt b/ext/xml/tests/utf8_encode_variation1.phpt index 4b5d3c5d3c..04b956c422 100644 --- a/ext/xml/tests/utf8_encode_variation1.phpt +++ b/ext/xml/tests/utf8_encode_variation1.phpt @@ -79,7 +79,7 @@ $values = array( // loop through each element of the array for data foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( utf8_encode($value) ); }; diff --git a/ext/xml/tests/xml001.phpt b/ext/xml/tests/xml001.phpt index 62d597c5f8..9c03b553cc 100644 --- a/ext/xml/tests/xml001.phpt +++ b/ext/xml/tests/xml001.phpt @@ -5,8 +5,6 @@ XML parser test, function callbacks require_once("skipif.inc"); XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); ?> ---INI-- -magic_quotes_runtime=0 --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/xml/tests/xml002.phpt b/ext/xml/tests/xml002.phpt index 8ae8dfbe66..ce547e8acc 100644 --- a/ext/xml/tests/xml002.phpt +++ b/ext/xml/tests/xml002.phpt @@ -5,8 +5,6 @@ XML parser test, object tuple callbacks require_once("skipif.inc"); XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); ?> ---INI-- -magic_quotes_runtime=0 --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/xml/tests/xml003.phpt b/ext/xml/tests/xml003.phpt index 311c81acfb..6b0c3f5c5a 100644 --- a/ext/xml/tests/xml003.phpt +++ b/ext/xml/tests/xml003.phpt @@ -5,8 +5,6 @@ XML parser test, xml_set_object callbacks require_once("skipif.inc"); XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); ?> ---INI-- -magic_quotes_runtime=0 --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/xml/tests/xml004.phpt b/ext/xml/tests/xml004.phpt index 78840ee122..245a93fc10 100644 --- a/ext/xml/tests/xml004.phpt +++ b/ext/xml/tests/xml004.phpt @@ -2,8 +2,6 @@ XML parser case folding test --SKIPIF-- <?php include("skipif.inc"); ?> ---INI-- -magic_quotes_runtime=0 --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/xml/tests/xml_closures_001.phpt b/ext/xml/tests/xml_closures_001.phpt index 5439a2a918..37df254190 100644 --- a/ext/xml/tests/xml_closures_001.phpt +++ b/ext/xml/tests/xml_closures_001.phpt @@ -2,8 +2,6 @@ XML parser test using closures as callbacks --SKIPIF-- <?php include("skipif.inc"); ?> ---INI-- -magic_quotes_runtime=0 --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/xml/tests/xml_error_string_variation1.phpt b/ext/xml/tests/xml_error_string_variation1.phpt index 2d21cd9c48..40b542c141 100644 --- a/ext/xml/tests/xml_error_string_variation1.phpt +++ b/ext/xml/tests/xml_error_string_variation1.phpt @@ -77,7 +77,7 @@ $values = array( // loop through each element of the array for code foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_error_string($value) ); }; diff --git a/ext/xml/tests/xml_get_current_byte_index_variation1.phpt b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt index 7f57ee3297..b5c83d78e9 100644 --- a/ext/xml/tests/xml_get_current_byte_index_variation1.phpt +++ b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt @@ -87,7 +87,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_get_current_byte_index($value) ); }; diff --git a/ext/xml/tests/xml_get_current_column_number_variation1.phpt b/ext/xml/tests/xml_get_current_column_number_variation1.phpt index 59db610291..0eeb8d078e 100644 --- a/ext/xml/tests/xml_get_current_column_number_variation1.phpt +++ b/ext/xml/tests/xml_get_current_column_number_variation1.phpt @@ -88,7 +88,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_get_current_column_number($value) ); }; diff --git a/ext/xml/tests/xml_get_current_line_number_variation1.phpt b/ext/xml/tests/xml_get_current_line_number_variation1.phpt index 0878dbb736..af41c6f9e8 100644 --- a/ext/xml/tests/xml_get_current_line_number_variation1.phpt +++ b/ext/xml/tests/xml_get_current_line_number_variation1.phpt @@ -87,7 +87,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_get_current_line_number($value) ); }; diff --git a/ext/xml/tests/xml_get_error_code_variation1.phpt b/ext/xml/tests/xml_get_error_code_variation1.phpt index 32caa52b5f..474921406a 100644 --- a/ext/xml/tests/xml_get_error_code_variation1.phpt +++ b/ext/xml/tests/xml_get_error_code_variation1.phpt @@ -87,7 +87,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_get_error_code($value) ); }; diff --git a/ext/xml/tests/xml_parse_into_struct_variation1.phpt b/ext/xml/tests/xml_parse_into_struct_variation1.phpt index 78b0cf43cd..fa1e8d2990 100644 --- a/ext/xml/tests/xml_parse_into_struct_variation1.phpt +++ b/ext/xml/tests/xml_parse_into_struct_variation1.phpt @@ -88,7 +88,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parse_into_struct($value, $data, $struct, $index) ); }; diff --git a/ext/xml/tests/xml_parse_variation1.phpt b/ext/xml/tests/xml_parse_variation1.phpt index 23f199a4dc..cf36666499 100644 --- a/ext/xml/tests/xml_parse_variation1.phpt +++ b/ext/xml/tests/xml_parse_variation1.phpt @@ -89,7 +89,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parse($value, $data, $isFinal) ); }; diff --git a/ext/xml/tests/xml_parser_create_ns_variation1.phpt b/ext/xml/tests/xml_parser_create_ns_variation1.phpt index 5446a4f3ee..2818b82fe8 100644 --- a/ext/xml/tests/xml_parser_create_ns_variation1.phpt +++ b/ext/xml/tests/xml_parser_create_ns_variation1.phpt @@ -91,7 +91,7 @@ $values = array( // loop through each element of the array for encoding foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; $res = xml_parser_create_ns($value); var_dump($res); if ($res !== false) { diff --git a/ext/xml/tests/xml_parser_create_variation1.phpt b/ext/xml/tests/xml_parser_create_variation1.phpt index 445b40d08e..c5d588fec3 100644 --- a/ext/xml/tests/xml_parser_create_variation1.phpt +++ b/ext/xml/tests/xml_parser_create_variation1.phpt @@ -91,7 +91,7 @@ $values = array( // loop through each element of the array for encoding foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; $res = xml_parser_create($value); var_dump($res); if ($res !== false) { diff --git a/ext/xml/tests/xml_parser_free_variation1.phpt b/ext/xml/tests/xml_parser_free_variation1.phpt index 4b4de5d05b..0ecb1092c8 100644 --- a/ext/xml/tests/xml_parser_free_variation1.phpt +++ b/ext/xml/tests/xml_parser_free_variation1.phpt @@ -87,7 +87,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_free($value) ); }; diff --git a/ext/xml/tests/xml_parser_get_option_variation1.phpt b/ext/xml/tests/xml_parser_get_option_variation1.phpt index 4edf1d6a0b..b53f803188 100644 --- a/ext/xml/tests/xml_parser_get_option_variation1.phpt +++ b/ext/xml/tests/xml_parser_get_option_variation1.phpt @@ -88,7 +88,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_get_option($value, $option) ); }; diff --git a/ext/xml/tests/xml_parser_get_option_variation2.phpt b/ext/xml/tests/xml_parser_get_option_variation2.phpt index de82111f83..2341c413f1 100644 --- a/ext/xml/tests/xml_parser_get_option_variation2.phpt +++ b/ext/xml/tests/xml_parser_get_option_variation2.phpt @@ -86,7 +86,7 @@ $values = array( // loop through each element of the array for option foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_get_option($parser, $value) ); }; diff --git a/ext/xml/tests/xml_parser_set_option_variation1.phpt b/ext/xml/tests/xml_parser_set_option_variation1.phpt index e3e3df8319..6cfce0b4e3 100644 --- a/ext/xml/tests/xml_parser_set_option_variation1.phpt +++ b/ext/xml/tests/xml_parser_set_option_variation1.phpt @@ -88,7 +88,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_set_option($value, $option, 1) ); }; diff --git a/ext/xml/tests/xml_parser_set_option_variation2.phpt b/ext/xml/tests/xml_parser_set_option_variation2.phpt index 6f84ebb696..9900d6fe6a 100644 --- a/ext/xml/tests/xml_parser_set_option_variation2.phpt +++ b/ext/xml/tests/xml_parser_set_option_variation2.phpt @@ -81,7 +81,7 @@ $values = array( // loop through each element of the array for option foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_set_option($parser, $value, 1) ); }; diff --git a/ext/xml/tests/xml_parser_set_option_variation3.phpt b/ext/xml/tests/xml_parser_set_option_variation3.phpt index 5f98803905..c215ef5fde 100644 --- a/ext/xml/tests/xml_parser_set_option_variation3.phpt +++ b/ext/xml/tests/xml_parser_set_option_variation3.phpt @@ -90,7 +90,7 @@ $values = array( // loop through each element of the array for value foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_parser_set_option($parser, $option, $value) ); }; diff --git a/ext/xml/tests/xml_set_character_data_handler_variation1.phpt b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt index bd384c9b62..40cff9193f 100644 --- a/ext/xml/tests/xml_set_character_data_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_character_data_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_default_handler_variation1.phpt b/ext/xml/tests/xml_set_default_handler_variation1.phpt index a887e01673..35089a066a 100644 --- a/ext/xml/tests/xml_set_default_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_default_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_default_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_element_handler_variation1.phpt b/ext/xml/tests/xml_set_element_handler_variation1.phpt index 83f370afea..225cf770b3 100644 --- a/ext/xml/tests/xml_set_element_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_element_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_element_handler($value, $hdl, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt index c2fcacfe8b..c7c2f6f176 100644 --- a/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_end_namespace_decl_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt index 1ad6a11279..10835b33b2 100644 --- a/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_external_entity_ref_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt index d89b04d2a5..d41e691edc 100644 --- a/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_notation_decl_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_object_variation1.phpt b/ext/xml/tests/xml_set_object_variation1.phpt index cc40445725..851dfaff10 100644 --- a/ext/xml/tests/xml_set_object_variation1.phpt +++ b/ext/xml/tests/xml_set_object_variation1.phpt @@ -88,7 +88,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_object($value, $obj) ); }; diff --git a/ext/xml/tests/xml_set_object_variation2.phpt b/ext/xml/tests/xml_set_object_variation2.phpt index 210544c45d..0844661786 100644 --- a/ext/xml/tests/xml_set_object_variation2.phpt +++ b/ext/xml/tests/xml_set_object_variation2.phpt @@ -80,7 +80,7 @@ $values = array( // loop through each element of the array for obj foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_object($parser, $value) ); }; diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt index 74cc1e5580..9da14cc5fd 100644 --- a/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_processing_instruction_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt index c0323b36ae..684a0fdac4 100644 --- a/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_start_namespace_decl_handler($value, $hdl) ); }; diff --git a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt index 04290fa4e1..1804115021 100644 --- a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt +++ b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt @@ -92,7 +92,7 @@ $values = array( // loop through each element of the array for parser foreach($values as $value) { - echo "\nArg value $value \n"; + echo @"\nArg value $value \n"; var_dump( xml_set_unparsed_entity_decl_handler($value, $hdl) ); }; diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 1f0480b6c7..391e318a2d 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -32,6 +32,7 @@ #include "zend_variables.h" #include "ext/standard/php_string.h" #include "ext/standard/info.h" +#include "ext/standard/html.h" #if HAVE_XML @@ -659,107 +660,6 @@ PHPAPI char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char } /* }}} */ -/* copied from trunk's implementation of get_next_char in ext/standard/html.c */ -#define MB_FAILURE(pos, advance) do { \ - *cursor = pos + (advance); \ - *status = FAILURE; \ - return 0; \ -} while (0) - -#define CHECK_LEN(pos, chars_need) ((str_len - (pos)) >= (chars_need)) -#define utf8_lead(c) ((c) < 0x80 || ((c) >= 0xC2 && (c) <= 0xF4)) -#define utf8_trail(c) ((c) >= 0x80 && (c) <= 0xBF) - -/* {{{ php_next_utf8_char - */ -static inline unsigned int php_next_utf8_char( - const unsigned char *str, - size_t str_len, - size_t *cursor, - int *status) -{ - size_t pos = *cursor; - unsigned int this_char = 0; - unsigned char c; - - *status = SUCCESS; - - if (!CHECK_LEN(pos, 1)) - MB_FAILURE(pos, 1); - - /* We'll follow strategy 2. from section 3.6.1 of UTR #36: - * "In a reported illegal byte sequence, do not include any - * non-initial byte that encodes a valid character or is a leading - * byte for a valid sequence.» */ - c = str[pos]; - if (c < 0x80) { - this_char = c; - pos++; - } else if (c < 0xc2) { - MB_FAILURE(pos, 1); - } else if (c < 0xe0) { - if (!CHECK_LEN(pos, 2)) - MB_FAILURE(pos, 1); - - if (!utf8_trail(str[pos + 1])) { - MB_FAILURE(pos, utf8_lead(str[pos + 1]) ? 1 : 2); - } - this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f); - if (this_char < 0x80) { /* non-shortest form */ - MB_FAILURE(pos, 2); - } - pos += 2; - } else if (c < 0xf0) { - size_t avail = str_len - pos; - - if (avail < 3 || - !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2])) { - if (avail < 2 || utf8_lead(str[pos + 1])) - MB_FAILURE(pos, 1); - else if (avail < 3 || utf8_lead(str[pos + 2])) - MB_FAILURE(pos, 2); - else - MB_FAILURE(pos, 3); - } - - this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f); - if (this_char < 0x800) { /* non-shortest form */ - MB_FAILURE(pos, 3); - } else if (this_char >= 0xd800 && this_char <= 0xdfff) { /* surrogate */ - MB_FAILURE(pos, 3); - } - pos += 3; - } else if (c < 0xf5) { - size_t avail = str_len - pos; - - if (avail < 4 || - !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2]) || - !utf8_trail(str[pos + 3])) { - if (avail < 2 || utf8_lead(str[pos + 1])) - MB_FAILURE(pos, 1); - else if (avail < 3 || utf8_lead(str[pos + 2])) - MB_FAILURE(pos, 2); - else if (avail < 4 || utf8_lead(str[pos + 3])) - MB_FAILURE(pos, 3); - else - MB_FAILURE(pos, 4); - } - - this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f); - if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */ - MB_FAILURE(pos, 4); - } - pos += 4; - } else { - MB_FAILURE(pos, 1); - } - - *cursor = pos; - return this_char; -} -/* }}} */ - - /* {{{ xml_utf8_decode */ PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding) { |
