Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a24ea50d
Commit
a24ea50d
authored
Apr 23, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5338 XML parser accepts malformed data
parent
213f1036
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
6 deletions
+40
-6
mysql-test/r/xml.result
mysql-test/r/xml.result
+20
-1
mysql-test/t/xml.test
mysql-test/t/xml.test
+15
-1
strings/xml.c
strings/xml.c
+5
-4
No files found.
mysql-test/r/xml.result
View file @
a24ea50d
...
...
@@ -132,7 +132,7 @@ xb1 xc1
SELECT extractValue(@xml,'/a//@x[2]');
extractValue(@xml,'/a//@x[2]')
xb2 xc2
SET @xml='
<a><b>
b1
</b><b>
b2
</b><c><b>
c1b1
</b><b>
c1b2
</b></c><c><b>
c2b1
</
c></b
></a>
';
SET @xml='
<a><b>
b1
</b><b>
b2
</b><c><b>
c1b1
</b><b>
c1b2
</b></c><c><b>
c2b1
</
b></c
></a>
';
SELECT extractValue(@xml,'//b[1]');
extractValue(@xml,'//b[1]')
b1 c1b1 c2b1
...
...
@@ -1133,3 +1133,22 @@ NULL
Warnings:
Warning
1525
Incorrect
XML
value:
'
parse
error
at
line
1
pos
11:
STRING
unexpected
(
ident
or
'/'
wanted
)'
End
of
5
.
1
tests
#
#
Start
of
5
.
3
tests
#
#
#
MDEV-5338
XML
parser
accepts
malformed
data
#
SELECT
ExtractValue
('<
a
>
xxx
</c>
','/a/b');
ExtractValue('
<a>
xxx
</c>
','/a/b')
NULL
Warnings:
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 10: '
</c>
' unexpected ('
</a>
' wanted)'
SELECT ExtractValue('
<a><b>
xxx
</c></a>
','/a/b');
ExtractValue('
<a><b>
xxx
</c></a>
','/a/b')
NULL
Warnings:
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 13: '
</c>
' unexpected ('
</b>
' wanted)'
#
# End of 5.3 tests
#
mysql-test/t/xml.test
View file @
a24ea50d
...
...
@@ -53,7 +53,7 @@ SELECT extractValue(@xml,'/a//@x');
SELECT
extractValue
(
@
xml
,
'/a//@x[1]'
);
SELECT
extractValue
(
@
xml
,
'/a//@x[2]'
);
SET
@
xml
=
'<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</
c></b
></a>'
;
SET
@
xml
=
'<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</
b></c
></a>'
;
SELECT
extractValue
(
@
xml
,
'//b[1]'
);
SELECT
extractValue
(
@
xml
,
'/descendant::b[1]'
);
...
...
@@ -652,3 +652,17 @@ SELECT UPDATEXML(CONVERT(_latin1'<!--' USING utf8),'1','1');
SELECT
ExtractValue
(
CONVERT
(
'<\"'
,
BINARY
(
10
)),
1
);
--
echo
End
of
5.1
tests
--
echo
#
--
echo
# Start of 5.3 tests
--
echo
#
--
echo
#
--
echo
# MDEV-5338 XML parser accepts malformed data
--
echo
#
SELECT
ExtractValue
(
'<a>xxx</c>'
,
'/a/b'
);
SELECT
ExtractValue
(
'<a><b>xxx</c></a>'
,
'/a/b'
);
--
echo
#
--
echo
# End of 5.3 tests
--
echo
#
strings/xml.c
View file @
a24ea50d
...
...
@@ -240,7 +240,7 @@ static void mstr(char *s,const char *src,size_t l1, size_t l2)
static
int
my_xml_leave
(
MY_XML_PARSER
*
p
,
const
char
*
str
,
size_t
slen
)
{
char
*
e
;
char
*
e
,
*
tag
;
size_t
glen
;
char
s
[
32
];
char
g
[
32
];
...
...
@@ -249,13 +249,14 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, size_t slen)
/* Find previous '/' or beginning */
for
(
e
=
p
->
attrend
;
(
e
>
p
->
attr
)
&&
(
e
[
0
]
!=
'/'
)
;
e
--
);
glen
=
(
size_t
)
((
e
[
0
]
==
'/'
)
?
(
p
->
attrend
-
e
-
1
)
:
p
->
attrend
-
e
);
if
(
str
&&
(
slen
!=
glen
))
tag
=
e
[
0
]
==
'/'
?
e
+
1
:
e
;
if
(
str
&&
(
slen
!=
glen
||
memcmp
(
str
,
tag
,
slen
)))
{
mstr
(
s
,
str
,
sizeof
(
s
)
-
1
,
slen
);
if
(
glen
)
{
mstr
(
g
,
e
+
1
,
sizeof
(
g
)
-
1
,
glen
),
mstr
(
g
,
tag
,
sizeof
(
g
)
-
1
,
glen
);
sprintf
(
p
->
errstr
,
"'</%s>' unexpected ('</%s>' wanted)"
,
s
,
g
);
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment