Browse Source

fix for bug #29657 xml_* functions throw non descriptive error, compared to php4

fix for bug #29711 libxml and non iso-8859-1.
If no encoding specified, it defaults to UTF-8 now
PHP-5.1
Christian Stocker 22 years ago
parent
commit
5950725144
  1. 128
      ext/xml/compat.c
  2. 4
      ext/xml/xml.c

128
ext/xml/compat.c

@ -463,9 +463,9 @@ const XML_Char *error_mapping[] = {
"No error",
"Internal error",
"No memory",
"XML_ERR_DOCUMENT_START",
"Invalid document start",
"Empty document",
"XML_ERR_DOCUMENT_END",
"Invalid document end",
"Invalid hexadecimal character reference",
"Invalid decimal character reference",
"Invalid character reference",
@ -478,14 +478,14 @@ const XML_Char *error_mapping[] = {
"XML_ERR_ENTITYREF_IN_PROLOG",
"XML_ERR_ENTITYREF_IN_EPILOG",
"XML_ERR_ENTITYREF_IN_DTD",
"XML_ERR_PEREF_AT_EOF",
"XML_ERR_PEREF_IN_PROLOG",
"XML_ERR_PEREF_IN_EPILOG",
"XML_ERR_PEREF_IN_INT_SUBSET",
"PEReference at end of document",
"PEReference in prolog",
"PEReference in epilog",
"PEReference: forbidden within markup decl in internal subset",
"XML_ERR_ENTITYREF_NO_NAME",
"XML_ERR_ENTITYREF_SEMICOL_MISSING",
"XML_ERR_PEREF_NO_NAME",
"XML_ERR_PEREF_SEMICOL_MISSING",
"EntityRef: expecting ';'",
"PEReference: no name",
"PEReference: expecting ';'",
"Undeclared entity error",
"Undeclared entity warning",
"Unparsed Entity",
@ -493,82 +493,82 @@ const XML_Char *error_mapping[] = {
"XML_ERR_ENTITY_IS_PARAMETER",
"Unknown encoding",
"Unsupported encoding",
"XML_ERR_STRING_NOT_STARTED",
"XML_ERR_STRING_NOT_CLOSED",
"String not started expecting ' or \"",
"String not closed expecting \" or '",
"Namespace declaration error",
"XML_ERR_ENTITY_NOT_STARTED",
"XML_ERR_ENTITY_NOT_FINISHED",
"XML_ERR_LT_IN_ATTRIBUTE",
"XML_ERR_ATTRIBUTE_NOT_STARTED",
"XML_ERR_ATTRIBUTE_NOT_FINISHED",
"XML_ERR_ATTRIBUTE_WITHOUT_VALUE",
"XML_ERR_ATTRIBUTE_REDEFINED",
"XML_ERR_LITERAL_NOT_STARTED",
"XML_ERR_LITERAL_NOT_FINISHED",
"EntityValue: \" or ' expected",
"EntityValue: \" or ' expected",
"< in attribute",
"Attribute not started",
"Attribute not finished",
"Attribute without value",
"Attribute redefined",
"SystemLiteral \" or ' expected",
"SystemLiteral \" or ' expected",
/* "XML_ERR_COMMENT_NOT_STARTED", <= eliminated on purpose */
"XML_ERR_COMMENT_NOT_FINISHED",
"XML_ERR_PI_NOT_STARTED",
"XML_ERR_PI_NOT_FINISHED",
"XML_ERR_NOTATION_NOT_STARTED",
"XML_ERR_NOTATION_NOT_FINISHED",
"XML_ERR_ATTLIST_NOT_STARTED",
"XML_ERR_ATTLIST_NOT_FINISHED",
"XML_ERR_MIXED_NOT_STARTED",
"Comment not finished",
"Processing Instruction not started",
"Processing Instruction not finished",
"NOTATION: Name expected here",
"'>' required to close NOTATION declaration",
"'(' required to start ATTLIST enumeration",
"'(' required to start ATTLIST enumeration",
"MixedContentDecl : '|' or ')*' expected",
"XML_ERR_MIXED_NOT_FINISHED",
"XML_ERR_ELEMCONTENT_NOT_STARTED",
"XML_ERR_ELEMCONTENT_NOT_FINISHED",
"XML_ERR_XMLDECL_NOT_STARTED",
"XML_ERR_XMLDECL_NOT_FINISHED",
"ELEMENT in DTD not started",
"ELEMENT in DTD not finished",
"XML declaration not started",
"XML declaration not finished",
"XML_ERR_CONDSEC_NOT_STARTED",
"XML_ERR_CONDSEC_NOT_FINISHED",
"XML_ERR_EXT_SUBSET_NOT_FINISHED",
"XML_ERR_DOCTYPE_NOT_FINISHED",
"XML_ERR_MISPLACED_CDATA_END",
"XML_ERR_CDATA_NOT_FINISHED",
"XML_ERR_RESERVED_XML_NAME",
"XML_ERR_SPACE_REQUIRED",
"XML conditional section not closed",
"Content error in the external subset",
"DOCTYPE not finished",
"Sequence ']]>' not allowed in content",
"CDATA not finished",
"Reserved XML Name",
"Space required",
"XML_ERR_SEPARATOR_REQUIRED",
"XML_ERR_NMTOKEN_REQUIRED",
"NmToken expected in ATTLIST enumeration",
"XML_ERR_NAME_REQUIRED",
"XML_ERR_PCDATA_REQUIRED",
"XML_ERR_URI_REQUIRED",
"XML_ERR_PUBID_REQUIRED",
"XML_ERR_LT_REQUIRED",
"XML_ERR_GT_REQUIRED",
"XML_ERR_LTSLASH_REQUIRED",
"XML_ERR_EQUAL_REQUIRED",
"XML_ERR_TAG_NAME_MISMATCH",
"XML_ERR_TAG_NOT_FINISHED",
"XML_ERR_STANDALONE_VALUE",
"XML_ERR_ENCODING_NAME",
"XML_ERR_HYPHEN_IN_COMMENT",
"MixedContentDecl : '#PCDATA' expected",
"SYSTEM or PUBLIC, the URI is missing",
"PUBLIC, the Public Identifier is missing",
"< required",
"> required",
"</ required",
"= required",
"Mismatched tag",
"Tag not finished",
"standalone accepts only 'yes' or 'no'",
"Invalid XML encoding name",
"Comment must not contain '--' (double-hyphen)",
"Invalid encoding",
"XML_ERR_EXT_ENTITY_STANDALONE",
"XML_ERR_CONDSEC_INVALID",
"XML_ERR_VALUE_REQUIRED",
"XML_ERR_NOT_WELL_BALANCED",
"XML_ERR_EXTRA_CONTENT",
"external parsed entities cannot be standalone",
"XML conditional section '[' expected",
"Entity value required",
"chunk is not well balanced",
"extra content at the end of well balanced chunk",
"XML_ERR_ENTITY_CHAR_ERROR",
"XML_ERR_ENTITY_PE_INTERNAL",
"XML_ERR_ENTITY_LOOP",
"PEReferences forbidden in internal subset",
"Detected an entity reference loop",
"XML_ERR_ENTITY_BOUNDARY",
"Invalid URI",
"XML_ERR_URI_FRAGMENT",
"Fragment not allowed",
"XML_WAR_CATALOG_PI",
"XML_ERR_NO_DTD",
"XML_ERR_CONDSEC_INVALID_KEYWORD", /* 95 */
"XML_ERR_VERSION_MISSING", /* 96 */
"conditional section INCLUDE or IGNORE keyword expected", /* 95 */
"Version in XML Declaration missing", /* 96 */
"XML_WAR_UNKNOWN_VERSION", /* 97 */
"XML_WAR_LANG_VALUE", /* 98 */
"XML_WAR_NS_URI", /* 99 */
"XML_WAR_NS_URI_RELATIVE", /* 100 */
"XML_ERR_MISSING_ENCODING" /* 101 */
"Missing encoding in text declaration" /* 101 */
};
PHPAPI const XML_Char *
XML_ErrorString(int code)
{
if (code < 0 || code >= (int)sizeof(error_mapping)) {
if (code < 0 || code >= (int)(sizeof(error_mapping) / sizeof(error_mapping[0]))) {
return "Unknown";
}
return error_mapping[code];

4
ext/xml/xml.c

@ -176,7 +176,7 @@ static int le_xml_parser;
#ifdef ZTS
static void php_xml_init_globals(php_xml_globals *xml_globals_p TSRMLS_DC)
{
XML(default_encoding) = "ISO-8859-1";
XML(default_encoding) = "UTF-8";
}
#endif
@ -204,7 +204,7 @@ PHP_MINIT_FUNCTION(xml)
#ifdef ZTS
ts_allocate_id(&xml_globals_id, sizeof(php_xml_globals), (ts_allocate_ctor) php_xml_init_globals, NULL);
#else
XML(default_encoding) = "ISO-8859-1";
XML(default_encoding) = "UTF-8";
#endif
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);

Loading…
Cancel
Save