diff options
author | bar@mysql.com <> | 2006-04-17 14:40:25 +0500 |
---|---|---|
committer | bar@mysql.com <> | 2006-04-17 14:40:25 +0500 |
commit | 8fb685c254fb7eac0a87d79132a2a72415d86397 (patch) | |
tree | ad61da58fe13bee1f57a91497b08bc491cec4c3d /sql/item_xmlfunc.cc | |
parent | 6f5999e9b5ffa775e8d3c0510e8b2c6a6ef2b1e7 (diff) | |
download | mariadb-git-8fb685c254fb7eac0a87d79132a2a72415d86397.tar.gz |
Bug#18201: XML: ExtractValue works even if the xml
fragment is not well-formed xml
Problem:
- ExtractValue silently returned NULL if a wrong XML value is passed.
- In some cases "unexpected END-OF-INPUT" error was not detected, and
a non-NULL result could be returned for a bad XML value.
Fix:
- Adding warning messages, to make user aware why NULL was returned.
- Missing "unexpected END-OF-INPUT" error is reported now.
Diffstat (limited to 'sql/item_xmlfunc.cc')
-rw-r--r-- | sql/item_xmlfunc.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 71900c26c2d..6bbbf67e074 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2563,7 +2563,17 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) xml_enter(&p, raw_xml->ptr(), 0); /* Execute XML parser */ - rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length()); + if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) + { + char buf[128]; + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %d: %s", + my_xml_error_lineno(&p) + 1, + my_xml_error_pos(&p) + 1, + my_xml_error_string(&p)); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WRONG_VALUE, + ER(ER_WRONG_VALUE), "XML", buf); + } my_xml_parser_free(&p); return rc == MY_XML_OK ? parsed_xml_buf : 0; |