mirror of
https://github.com/MariaDB/server.git
synced 2026-05-03 13:45:34 +02:00
Bug #18172 XML: Extractvalue() accepts mallformed
XPath without a XPath syntax error item_xmlfunc.cc: Error message didn't happen because after a failing attempt to parse RelativeLocationPath, my_xpath_parse_AbsoluteLocationPath() returned success. Changeing logic a bit: - Try to parse EOF first, return success if true. - Then try to parse RelativeLocationPath(), return success if true. - Otherwise return failure. xml.result: Adding test case. Also, this change made it possible to generate an error message earlier in the case of another bad XPATH syntax. xml.test: Adding test case. sql/item_xmlfunc.cc: Bug #18172 XML: Extractvalue() accepts mallformed XPath without a XPath syntax error Error message didn't happen because after a failing attempt to parse RelativeLocationPath(), my_xpath_parse_AbsoluteLocationPath() returned with 1. Changeing logic a bit: check for EOF first. Then try to parse RelativeLocationPath(). If the latter fails, return failure. mysql-test/t/xml.test: Adding test case. mysql-test/r/xml.result: Adding test case. Also, this change makes error message to be generated earlier in the case of another bad XPATH syntax.
This commit is contained in:
parent
f9dd31ca8e
commit
5f8bd7fe0f
3 changed files with 16 additions and 2 deletions
|
|
@ -546,7 +546,7 @@ select extractvalue('<a>a<b>B</b></a>','a|/b');
|
||||||
extractvalue('<a>a<b>B</b></a>','a|/b')
|
extractvalue('<a>a<b>B</b></a>','a|/b')
|
||||||
a
|
a
|
||||||
select extractvalue('<a>A</a>','/<a>');
|
select extractvalue('<a>A</a>','/<a>');
|
||||||
ERROR HY000: XPATH syntax error: '>'
|
ERROR HY000: XPATH syntax error: '<a>'
|
||||||
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
|
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
|
||||||
ERROR HY000: XPATH syntax error: '!'
|
ERROR HY000: XPATH syntax error: '!'
|
||||||
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
|
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
|
||||||
|
|
@ -613,3 +613,5 @@ select extractValue('<e>1</e>','position()');
|
||||||
ERROR HY000: XPATH syntax error: ''
|
ERROR HY000: XPATH syntax error: ''
|
||||||
select extractValue('<e>1</e>','last()');
|
select extractValue('<e>1</e>','last()');
|
||||||
ERROR HY000: XPATH syntax error: ''
|
ERROR HY000: XPATH syntax error: ''
|
||||||
|
select extractValue('<e><a>1</a></e>','/e/');
|
||||||
|
ERROR HY000: XPATH syntax error: ''
|
||||||
|
|
|
||||||
|
|
@ -286,3 +286,12 @@ select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
|
||||||
select extractValue('<e>1</e>','position()');
|
select extractValue('<e>1</e>','position()');
|
||||||
--error 1105
|
--error 1105
|
||||||
select extractValue('<e>1</e>','last()');
|
select extractValue('<e>1</e>','last()');
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #18172 XML: Extractvalue() accepts mallformed
|
||||||
|
# XPath without a XPath syntax error
|
||||||
|
#
|
||||||
|
--error 1105
|
||||||
|
select extractValue('<e><a>1</a></e>','/e/');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1561,10 +1561,13 @@ static int my_xpath_parse_AbsoluteLocationPath(MY_XPATH *xpath)
|
||||||
return my_xpath_parse_RelativeLocationPath(xpath);
|
return my_xpath_parse_RelativeLocationPath(xpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (my_xpath_parse_term(xpath, MY_XPATH_LEX_EOF))
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (my_xpath_parse_RelativeLocationPath(xpath))
|
if (my_xpath_parse_RelativeLocationPath(xpath))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue