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
17f72b8b
Commit
17f72b8b
authored
May 20, 2011
by
Adam Martinson
Committed by
Alexandre Julliard
May 20, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3/domdoc: Properly handle character encoding in doparse().
parent
af9eeb00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
25 deletions
+9
-25
domdoc.c
dlls/msxml3/domdoc.c
+9
-25
No files found.
dlls/msxml3/domdoc.c
View file @
17f72b8b
...
...
@@ -455,7 +455,7 @@ static void sax_serror(void* ctx, xmlErrorPtr err)
LIBXML2_CALLBACK_SERROR
(
doparse
,
err
);
}
static
xmlDocPtr
doparse
(
domdoc
*
This
,
char
*
ptr
,
int
len
,
xmlChar
const
*
encoding
)
static
xmlDocPtr
doparse
(
domdoc
*
This
,
char
const
*
ptr
,
int
len
,
xmlCharEncoding
encoding
)
{
xmlDocPtr
doc
=
NULL
;
xmlParserCtxtPtr
pctx
;
...
...
@@ -506,7 +506,10 @@ static xmlDocPtr doparse(domdoc* This, char *ptr, int len, xmlChar const* encodi
pctx
->
sax
=
&
sax_handler
;
pctx
->
_private
=
This
;
pctx
->
recovery
=
0
;
pctx
->
encoding
=
xmlStrdup
(
encoding
);
if
(
encoding
!=
XML_CHAR_ENCODING_NONE
)
xmlSwitchEncoding
(
pctx
,
encoding
);
xmlParseDocument
(
pctx
);
if
(
pctx
->
wellFormed
)
...
...
@@ -763,7 +766,7 @@ static HRESULT WINAPI domdoc_IPersistStreamInit_Load(
len
=
GlobalSize
(
hglobal
);
ptr
=
GlobalLock
(
hglobal
);
if
(
len
!=
0
)
xmldoc
=
doparse
(
This
,
ptr
,
len
,
NULL
);
xmldoc
=
doparse
(
This
,
ptr
,
len
,
XML_CHAR_ENCODING_NONE
);
GlobalUnlock
(
hglobal
);
if
(
!
xmldoc
)
...
...
@@ -2071,7 +2074,7 @@ static HRESULT domdoc_onDataAvailable(void *obj, char *ptr, DWORD len)
domdoc
*
This
=
obj
;
xmlDocPtr
xmldoc
;
xmldoc
=
doparse
(
This
,
ptr
,
len
,
NULL
);
xmldoc
=
doparse
(
This
,
ptr
,
len
,
XML_CHAR_ENCODING_NONE
);
if
(
xmldoc
)
{
xmldoc
->
_private
=
create_priv
();
return
attach_xmldoc
(
This
,
xmldoc
);
...
...
@@ -2279,21 +2282,6 @@ static HRESULT WINAPI domdoc_abort(
}
static
BOOL
bstr_to_utf8
(
BSTR
bstr
,
char
**
pstr
,
int
*
plen
)
{
UINT
len
;
LPSTR
str
;
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
bstr
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
str
=
heap_alloc
(
len
);
if
(
!
str
)
return
FALSE
;
WideCharToMultiByte
(
CP_UTF8
,
0
,
bstr
,
-
1
,
str
,
len
,
NULL
,
NULL
);
*
plen
=
len
;
*
pstr
=
str
;
return
TRUE
;
}
/* don't rely on data to be in BSTR format, treat it as WCHAR string */
static
HRESULT
WINAPI
domdoc_loadXML
(
IXMLDOMDocument3
*
iface
,
...
...
@@ -2301,11 +2289,8 @@ static HRESULT WINAPI domdoc_loadXML(
VARIANT_BOOL
*
isSuccessful
)
{
domdoc
*
This
=
impl_from_IXMLDOMDocument3
(
iface
);
static
const
xmlChar
encoding
[]
=
"UTF-8"
;
xmlDocPtr
xmldoc
=
NULL
;
HRESULT
hr
=
S_FALSE
,
hr2
;
char
*
str
;
int
len
;
TRACE
(
"(%p)->(%s %p)
\n
"
,
This
,
debugstr_w
(
bstrXML
),
isSuccessful
);
...
...
@@ -2315,10 +2300,9 @@ static HRESULT WINAPI domdoc_loadXML(
{
*
isSuccessful
=
VARIANT_FALSE
;
if
(
bstrXML
&&
bstr_to_utf8
(
bstrXML
,
&
str
,
&
len
)
)
if
(
bstrXML
)
{
xmldoc
=
doparse
(
This
,
str
,
len
,
encoding
);
heap_free
(
str
);
xmldoc
=
doparse
(
This
,
(
LPCSTR
)
bstrXML
,
lstrlenW
(
bstrXML
)
*
sizeof
(
*
bstrXML
),
XML_CHAR_ENCODING_UTF16LE
);
if
(
!
xmldoc
)
{
This
->
error
=
E_FAIL
;
...
...
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