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
221f9efe
Commit
221f9efe
authored
Apr 21, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Switch parser encoding manually when it won't be able to detect it (UTF-16 case).
parent
c5089d18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
saxreader.c
dlls/msxml3/saxreader.c
+26
-4
saxreader.c
dlls/msxml3/tests/saxreader.c
+16
-6
No files found.
dlls/msxml3/saxreader.c
View file @
221f9efe
...
...
@@ -2144,7 +2144,7 @@ static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int siz
HRESULT
hr
;
hr
=
SAXLocator_create
(
This
,
&
locator
,
vbInterface
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
return
hr
;
if
(
size
>=
4
)
...
...
@@ -2163,22 +2163,44 @@ static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int siz
}
}
/* if libxml2 detection failed try to guess */
if
(
encoding
==
XML_CHAR_ENCODING_NONE
)
{
const
WCHAR
*
ptr
=
(
WCHAR
*
)
buffer
;
/* xml declaration with possibly specfied encoding will be still handled by parser */
if
((
size
>=
2
)
&&
*
ptr
==
'<'
&&
ptr
[
1
]
!=
'?'
)
{
enc_name
=
(
xmlChar
*
)
xmlGetCharEncodingName
(
XML_CHAR_ENCODING_UTF16LE
);
encoding
=
XML_CHAR_ENCODING_UTF16LE
;
}
}
else
if
(
encoding
==
XML_CHAR_ENCODING_UTF8
)
enc_name
=
(
xmlChar
*
)
xmlGetCharEncodingName
(
encoding
);
else
enc_name
=
NULL
;
locator
->
pParserCtxt
=
xmlCreateMemoryParserCtxt
(
buffer
,
size
);
if
(
!
locator
->
pParserCtxt
)
if
(
!
locator
->
pParserCtxt
)
{
ISAXLocator_Release
(
&
locator
->
ISAXLocator_iface
);
return
E_FAIL
;
}
if
(
encoding
==
XML_CHAR_ENCODING_UTF8
)
if
(
enc_name
)
{
locator
->
pParserCtxt
->
encoding
=
xmlStrdup
(
enc_name
);
if
(
encoding
==
XML_CHAR_ENCODING_UTF16LE
)
{
TRACE
(
"switching to %s
\n
"
,
enc_name
);
xmlSwitchEncoding
(
locator
->
pParserCtxt
,
encoding
);
}
}
xmlFree
(
locator
->
pParserCtxt
->
sax
);
locator
->
pParserCtxt
->
sax
=
&
locator
->
saxreader
->
sax
;
locator
->
pParserCtxt
->
userData
=
locator
;
This
->
isParsing
=
TRUE
;
if
(
xmlParseDocument
(
locator
->
pParserCtxt
)
==-
1
&&
locator
->
ret
==
S_OK
)
if
(
xmlParseDocument
(
locator
->
pParserCtxt
)
==
-
1
&&
locator
->
ret
==
S_OK
)
hr
=
E_FAIL
;
else
hr
=
locator
->
ret
;
...
...
dlls/msxml3/tests/saxreader.c
View file @
221f9efe
...
...
@@ -2317,18 +2317,20 @@ static const struct enc_test_entry_t encoding_test_data[] = {
{
0
}
};
static
void
test_encoding
(
void
)
static
void
test_
saxreader_
encoding
(
void
)
{
const
struct
enc_test_entry_t
*
entry
=
encoding_test_data
;
static
const
WCHAR
testXmlW
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'.'
,
'x'
,
'm'
,
'l'
,
0
};
static
const
CHAR
testXmlA
[]
=
"test.xml"
;
ISAXXMLReader
*
reader
;
DWORD
written
;
HANDLE
file
;
HRESULT
hr
;
while
(
entry
->
guid
)
{
ISAXXMLReader
*
reader
;
VARIANT
input
;
DWORD
written
;
HANDLE
file
;
HRESULT
hr
;
hr
=
CoCreateInstance
(
entry
->
guid
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_ISAXXMLReader
,
(
void
**
)
&
reader
);
if
(
hr
!=
S_OK
)
{
...
...
@@ -2349,8 +2351,16 @@ static void test_encoding(void)
ok
(
hr
==
entry
->
hr
,
"Expected 0x%08x, got 0x%08x. CLSID %s
\n
"
,
entry
->
hr
,
hr
,
entry
->
clsid
);
DeleteFileA
(
testXmlA
);
/* try BSTR input with no BOM or '<?xml' instruction */
V_VT
(
&
input
)
=
VT_BSTR
;
V_BSTR
(
&
input
)
=
_bstr_
(
"<element></element>"
);
hr
=
ISAXXMLReader_parse
(
reader
,
input
);
EXPECT_HR
(
hr
,
S_OK
);
ISAXXMLReader_Release
(
reader
);
free_bstrs
();
entry
++
;
}
}
...
...
@@ -4474,7 +4484,7 @@ START_TEST(saxreader)
test_saxreader
();
test_saxreader_properties
();
test_saxreader_features
();
test_encoding
();
test_
saxreader_
encoding
();
test_dispex
();
/* MXXMLWriter tests */
...
...
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