Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
57497d12
Commit
57497d12
authored
Sep 14, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Handle empty prefix and uri correctly in WriteStartElement().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
225e7b34
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
+35
-11
writer.c
dlls/xmllite/tests/writer.c
+25
-1
writer.c
dlls/xmllite/writer.c
+10
-10
No files found.
dlls/xmllite/tests/writer.c
View file @
57497d12
...
...
@@ -1736,9 +1736,33 @@ static void test_WriteFullEndElement(void)
"<a>
\r\n
"
" <a></a>
\r\n
"
"</a>"
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
/* Empty strings for prefix and uri. */
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_SetProperty
(
writer
,
XmlWriterProperty_Indent
,
FALSE
);
ok
(
hr
==
S_OK
,
"Failed to set property, hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
L""
,
L"a"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"b"
,
L""
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
L""
,
L"c"
,
L""
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteFullEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteFullEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteFullEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<a><b><c></c></b></a>"
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
}
static
void
test_WriteCharEntity
(
void
)
...
...
dlls/xmllite/writer.c
View file @
57497d12
...
...
@@ -168,6 +168,11 @@ static inline void writer_free(const xmlwriter *writer, void *mem)
m_free
(
writer
->
imalloc
,
mem
);
}
static
BOOL
is_empty_string
(
const
WCHAR
*
str
)
{
return
!
str
||
!*
str
;
}
static
struct
element
*
alloc_element
(
xmlwriter
*
writer
,
const
WCHAR
*
prefix
,
const
WCHAR
*
local
)
{
struct
element
*
ret
;
...
...
@@ -176,7 +181,7 @@ static struct element *alloc_element(xmlwriter *writer, const WCHAR *prefix, con
ret
=
writer_alloc
(
writer
,
sizeof
(
*
ret
));
if
(
!
ret
)
return
ret
;
len
=
prefix
?
lstrlenW
(
prefix
)
+
1
/* ':' */
:
0
;
len
=
is_empty_string
(
prefix
)
?
0
:
lstrlenW
(
prefix
)
+
1
/* ':' */
;
len
+=
lstrlenW
(
local
);
ret
->
qname
=
writer_alloc
(
writer
,
(
len
+
1
)
*
sizeof
(
WCHAR
));
...
...
@@ -188,13 +193,13 @@ static struct element *alloc_element(xmlwriter *writer, const WCHAR *prefix, con
}
ret
->
len
=
len
;
if
(
prefix
)
if
(
is_empty_string
(
prefix
))
ret
->
qname
[
0
]
=
0
;
else
{
lstrcpyW
(
ret
->
qname
,
prefix
);
lstrcatW
(
ret
->
qname
,
L":"
);
}
else
ret
->
qname
[
0
]
=
0
;
lstrcatW
(
ret
->
qname
,
local
);
list_init
(
&
ret
->
ns
);
...
...
@@ -288,11 +293,6 @@ static struct ns *writer_push_ns(xmlwriter *writer, const WCHAR *prefix, int pre
return
ns
;
}
static
BOOL
is_empty_string
(
const
WCHAR
*
str
)
{
return
!
str
||
!*
str
;
}
static
struct
ns
*
writer_find_ns_current
(
const
xmlwriter
*
writer
,
const
WCHAR
*
prefix
,
const
WCHAR
*
uri
)
{
struct
element
*
element
;
...
...
@@ -1676,7 +1676,7 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
writer_push_element
(
This
,
element
);
if
(
!
ns
&&
uri
)
if
(
!
ns
&&
!
is_empty_string
(
uri
)
)
writer_push_ns
(
This
,
prefix
,
prefix_len
,
uri
);
write_output_buffer_char
(
This
->
output
,
'<'
);
...
...
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