Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
48975081
Commit
48975081
authored
Feb 03, 2016
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Parse CDATA nodes.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
50797a80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
2 deletions
+134
-2
reader.c
dlls/webservices/reader.c
+67
-2
reader.c
dlls/webservices/tests/reader.c
+67
-0
No files found.
dlls/webservices/reader.c
View file @
48975081
...
...
@@ -329,6 +329,8 @@ void free_node( struct node *node )
heap_free
(
comment
->
value
.
bytes
);
break
;
}
case
WS_XML_NODE_TYPE_CDATA
:
case
WS_XML_NODE_TYPE_END_CDATA
:
case
WS_XML_NODE_TYPE_END_ELEMENT
:
case
WS_XML_NODE_TYPE_EOF
:
case
WS_XML_NODE_TYPE_BOF
:
...
...
@@ -386,8 +388,11 @@ enum reader_state
READER_STATE_STARTELEMENT
,
READER_STATE_STARTATTRIBUTE
,
READER_STATE_STARTENDELEMENT
,
READER_STATE_STARTCDATA
,
READER_STATE_CDATA
,
READER_STATE_TEXT
,
READER_STATE_ENDELEMENT
,
READER_STATE_ENDCDATA
,
READER_STATE_COMMENT
,
READER_STATE_EOF
};
...
...
@@ -1168,6 +1173,63 @@ static HRESULT read_comment( struct reader *reader )
return
S_OK
;
}
static
HRESULT
read_startcdata
(
struct
reader
*
reader
)
{
struct
node
*
node
;
if
(
read_cmp
(
reader
,
"<![CDATA["
,
9
))
return
WS_E_INVALID_FORMAT
;
read_skip
(
reader
,
9
);
if
(
!
(
node
=
alloc_node
(
WS_XML_NODE_TYPE_CDATA
)))
return
E_OUTOFMEMORY
;
read_insert_node
(
reader
,
reader
->
current
,
node
);
reader
->
state
=
READER_STATE_STARTCDATA
;
return
S_OK
;
}
static
HRESULT
read_cdata
(
struct
reader
*
reader
)
{
unsigned
int
len
=
0
,
ch
,
skip
;
const
unsigned
char
*
start
;
struct
node
*
node
;
WS_XML_TEXT_NODE
*
text
;
WS_XML_UTF8_TEXT
*
utf8
;
start
=
read_current_ptr
(
reader
);
for
(;;)
{
if
(
!
read_cmp
(
reader
,
"]]>"
,
3
))
break
;
if
(
!
(
ch
=
read_utf8_char
(
reader
,
&
skip
)))
return
WS_E_INVALID_FORMAT
;
read_skip
(
reader
,
skip
);
len
+=
skip
;
}
if
(
!
(
node
=
alloc_node
(
WS_XML_NODE_TYPE_TEXT
)))
return
E_OUTOFMEMORY
;
text
=
(
WS_XML_TEXT_NODE
*
)
node
;
if
(
!
(
utf8
=
alloc_utf8_text
(
start
,
len
)))
{
heap_free
(
node
);
return
E_OUTOFMEMORY
;
}
text
->
text
=
&
utf8
->
text
;
read_insert_node
(
reader
,
reader
->
current
,
node
);
reader
->
state
=
READER_STATE_CDATA
;
return
S_OK
;
}
static
HRESULT
read_endcdata
(
struct
reader
*
reader
)
{
struct
node
*
node
;
if
(
read_cmp
(
reader
,
"]]>"
,
3
))
return
WS_E_INVALID_FORMAT
;
read_skip
(
reader
,
3
);
if
(
!
(
node
=
alloc_node
(
WS_XML_NODE_TYPE_END_CDATA
)))
return
E_OUTOFMEMORY
;
read_insert_node
(
reader
,
reader
->
current
->
parent
,
node
);
reader
->
state
=
READER_STATE_ENDCDATA
;
return
S_OK
;
}
static
HRESULT
read_node
(
struct
reader
*
reader
)
{
HRESULT
hr
;
...
...
@@ -1181,13 +1243,16 @@ static HRESULT read_node( struct reader *reader )
reader
->
state
=
READER_STATE_EOF
;
return
S_OK
;
}
if
(
!
read_cmp
(
reader
,
"<?"
,
2
))
if
(
reader
->
state
==
READER_STATE_STARTCDATA
)
return
read_cdata
(
reader
);
else
if
(
reader
->
state
==
READER_STATE_CDATA
)
return
read_endcdata
(
reader
);
else
if
(
!
read_cmp
(
reader
,
"<?"
,
2
))
{
hr
=
read_xmldecl
(
reader
);
if
(
FAILED
(
hr
))
return
hr
;
}
else
if
(
!
read_cmp
(
reader
,
"</"
,
2
))
return
read_endelement
(
reader
);
else
if
(
!
read_cmp
(
reader
,
"<!"
,
2
))
return
read_comment
(
reader
);
else
if
(
!
read_cmp
(
reader
,
"<![CDATA["
,
9
))
return
read_startcdata
(
reader
);
else
if
(
!
read_cmp
(
reader
,
"<!--"
,
4
))
return
read_comment
(
reader
);
else
if
(
!
read_cmp
(
reader
,
"<"
,
1
))
return
read_startelement
(
reader
);
else
return
read_text
(
reader
);
}
...
...
dlls/webservices/tests/reader.c
View file @
48975081
...
...
@@ -1805,6 +1805,72 @@ static void test_simple_struct_type(void)
WsFreeHeap
(
heap
);
}
static
void
test_cdata
(
void
)
{
static
const
char
test
[]
=
"<t><![CDATA[<data>]]></t>"
;
HRESULT
hr
;
WS_XML_READER
*
reader
;
const
WS_XML_NODE
*
node
;
hr
=
WsCreateReader
(
NULL
,
0
,
&
reader
,
NULL
)
;
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFillReader
(
reader
,
sizeof
(
test
)
-
1
,
NULL
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_CDATA
,
"got %u
\n
"
,
node
->
nodeType
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
{
WS_XML_TEXT_NODE
*
text
=
(
WS_XML_TEXT_NODE
*
)
node
;
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_TEXT
,
"got %u
\n
"
,
node
->
nodeType
);
ok
(
text
->
text
!=
NULL
,
"text not set
\n
"
);
if
(
text
->
text
)
{
WS_XML_UTF8_TEXT
*
utf8
=
(
WS_XML_UTF8_TEXT
*
)
text
->
text
;
ok
(
utf8
->
text
.
textType
==
WS_XML_TEXT_TYPE_UTF8
,
"got %u
\n
"
,
utf8
->
text
.
textType
);
ok
(
utf8
->
value
.
length
==
6
,
"got %u
\n
"
,
utf8
->
value
.
length
);
ok
(
!
memcmp
(
utf8
->
value
.
bytes
,
"<data>"
,
6
),
"wrong data
\n
"
);
}
}
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_END_CDATA
,
"got %u
\n
"
,
node
->
nodeType
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_END_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
WsFreeReader
(
reader
);
}
START_TEST
(
reader
)
{
test_WsCreateError
();
...
...
@@ -1823,4 +1889,5 @@ START_TEST(reader)
test_WsAlloc
();
test_WsMoveReader
();
test_simple_struct_type
();
test_cdata
();
}
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