Skip to content

Commit bc0c69c

Browse files
author
[email protected]/bar.intranet.mysql.r18.ru
committed
Bug#20795: extractvalue() won't accept names containing a dot (.)
Dot character was not considered as a valid identifier body character.
1 parent dbaba24 commit bc0c69c

5 files changed

Lines changed: 46 additions & 33 deletions

File tree

mysql-test/r/xml.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,3 +704,9 @@ a
704704
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
705705
extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns')
706706
myns
707+
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar');
708+
extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar')
709+
Data
710+
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something');
711+
extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something')
712+
Otherdata

mysql-test/t/xml.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,9 @@ DROP PROCEDURE p2;
354354
select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
355355
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
356356
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
357+
358+
#
359+
# Bug#20795 extractvalue() won't accept names containing a dot (.)
360+
#
361+
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar');
362+
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something');

sql/item_xmlfunc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,8 @@ my_xpath_lex_scan(MY_XPATH *xpath,
13561356
(length= xpath->cs->cset->ctype(xpath->cs, &ctype,
13571357
(const uchar*) beg,
13581358
(const uchar*) end)) > 0 &&
1359-
((ctype & (_MY_L | _MY_U | _MY_NMR)) || *beg == '_' || *beg == '-') ;
1359+
((ctype & (_MY_L | _MY_U | _MY_NMR)) ||
1360+
*beg == '_' || *beg == '-' || *beg == '.') ;
13601361
beg+= length) /* no op */;
13611362
lex->end= beg;
13621363

strings/ctype.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,35 @@ struct my_cs_file_section_st
8080
static struct my_cs_file_section_st sec[] =
8181
{
8282
{_CS_MISC, "xml"},
83-
{_CS_MISC, "xml.version"},
84-
{_CS_MISC, "xml.encoding"},
83+
{_CS_MISC, "xml/version"},
84+
{_CS_MISC, "xml/encoding"},
8585
{_CS_MISC, "charsets"},
86-
{_CS_MISC, "charsets.max-id"},
87-
{_CS_CHARSET, "charsets.charset"},
88-
{_CS_PRIMARY_ID, "charsets.charset.primary-id"},
89-
{_CS_BINARY_ID, "charsets.charset.binary-id"},
90-
{_CS_CSNAME, "charsets.charset.name"},
91-
{_CS_FAMILY, "charsets.charset.family"},
92-
{_CS_CSDESCRIPT, "charsets.charset.description"},
93-
{_CS_MISC, "charsets.charset.alias"},
94-
{_CS_MISC, "charsets.charset.ctype"},
95-
{_CS_CTYPEMAP, "charsets.charset.ctype.map"},
96-
{_CS_MISC, "charsets.charset.upper"},
97-
{_CS_UPPERMAP, "charsets.charset.upper.map"},
98-
{_CS_MISC, "charsets.charset.lower"},
99-
{_CS_LOWERMAP, "charsets.charset.lower.map"},
100-
{_CS_MISC, "charsets.charset.unicode"},
101-
{_CS_UNIMAP, "charsets.charset.unicode.map"},
102-
{_CS_COLLATION, "charsets.charset.collation"},
103-
{_CS_COLNAME, "charsets.charset.collation.name"},
104-
{_CS_ID, "charsets.charset.collation.id"},
105-
{_CS_ORDER, "charsets.charset.collation.order"},
106-
{_CS_FLAG, "charsets.charset.collation.flag"},
107-
{_CS_COLLMAP, "charsets.charset.collation.map"},
108-
{_CS_RESET, "charsets.charset.collation.rules.reset"},
109-
{_CS_DIFF1, "charsets.charset.collation.rules.p"},
110-
{_CS_DIFF2, "charsets.charset.collation.rules.s"},
111-
{_CS_DIFF3, "charsets.charset.collation.rules.t"},
86+
{_CS_MISC, "charsets/max-id"},
87+
{_CS_CHARSET, "charsets/charset"},
88+
{_CS_PRIMARY_ID, "charsets/charset/primary-id"},
89+
{_CS_BINARY_ID, "charsets/charset/binary-id"},
90+
{_CS_CSNAME, "charsets/charset/name"},
91+
{_CS_FAMILY, "charsets/charset/family"},
92+
{_CS_CSDESCRIPT, "charsets/charset/description"},
93+
{_CS_MISC, "charsets/charset/alias"},
94+
{_CS_MISC, "charsets/charset/ctype"},
95+
{_CS_CTYPEMAP, "charsets/charset/ctype/map"},
96+
{_CS_MISC, "charsets/charset/upper"},
97+
{_CS_UPPERMAP, "charsets/charset/upper/map"},
98+
{_CS_MISC, "charsets/charset/lower"},
99+
{_CS_LOWERMAP, "charsets/charset/lower/map"},
100+
{_CS_MISC, "charsets/charset/unicode"},
101+
{_CS_UNIMAP, "charsets/charset/unicode/map"},
102+
{_CS_COLLATION, "charsets/charset/collation"},
103+
{_CS_COLNAME, "charsets/charset/collation/name"},
104+
{_CS_ID, "charsets/charset/collation/id"},
105+
{_CS_ORDER, "charsets/charset/collation/order"},
106+
{_CS_FLAG, "charsets/charset/collation/flag"},
107+
{_CS_COLLMAP, "charsets/charset/collation/map"},
108+
{_CS_RESET, "charsets/charset/collation/rules/reset"},
109+
{_CS_DIFF1, "charsets/charset/collation/rules/p"},
110+
{_CS_DIFF2, "charsets/charset/collation/rules/s"},
111+
{_CS_DIFF3, "charsets/charset/collation/rules/t"},
112112
{0, NULL}
113113
};
114114

strings/xml.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len)
159159
}
160160
if (st->attrend > st->attr)
161161
{
162-
st->attrend[0]='.';
162+
st->attrend[0]= '/';
163163
st->attrend++;
164164
}
165165
memcpy(st->attrend,str,len);
@@ -188,9 +188,9 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen)
188188
char g[32];
189189
int rc;
190190

191-
/* Find previous '.' or beginning */
192-
for( e=p->attrend; (e>p->attr) && (e[0] != '.') ; e--);
193-
glen = (uint) ((e[0] == '.') ? (p->attrend-e-1) : p->attrend-e);
191+
/* Find previous '/' or beginning */
192+
for( e=p->attrend; (e>p->attr) && (e[0] != '/') ; e--);
193+
glen = (uint) ((e[0] == '/') ? (p->attrend-e-1) : p->attrend-e);
194194

195195
if (str && (slen != glen))
196196
{

0 commit comments

Comments
 (0)