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
cdaf5625
Commit
cdaf5625
authored
Jan 23, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Use IUri API to load documents.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
de90cca5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
75 deletions
+118
-75
bsc.c
dlls/msxml3/bsc.c
+20
-5
domdoc.c
dlls/msxml3/domdoc.c
+21
-28
msxml_private.h
dlls/msxml3/msxml_private.h
+1
-0
domdoc.c
dlls/msxml3/tests/domdoc.c
+76
-42
No files found.
dlls/msxml3/bsc.c
View file @
cdaf5625
...
...
@@ -242,24 +242,24 @@ static const struct IBindStatusCallbackVtbl bsc_vtbl =
bsc_OnObjectAvailable
};
HRESULT
create_
moniker_from_url
(
LPCWSTR
url
,
IMoniker
**
mon
)
HRESULT
create_
uri
(
const
WCHAR
*
url
,
IUri
**
uri
)
{
WCHAR
fileUrl
[
INTERNET_MAX_URL_LENGTH
];
TRACE
(
"%s
\n
"
,
debugstr_w
(
url
));
if
(
!
PathIsURLW
(
url
))
if
(
!
PathIsURLW
(
url
))
{
WCHAR
fullpath
[
MAX_PATH
];
DWORD
needed
=
sizeof
(
fileUrl
)
/
sizeof
(
WCHAR
);
if
(
!
PathSearchAndQualifyW
(
url
,
fullpath
,
sizeof
(
fullpath
)
/
sizeof
(
WCHAR
)))
if
(
!
PathSearchAndQualifyW
(
url
,
fullpath
,
sizeof
(
fullpath
)
/
sizeof
(
WCHAR
)))
{
WARN
(
"can't find path
\n
"
);
return
E_FAIL
;
}
if
(
FAILED
(
UrlCreateFromPathW
(
fullpath
,
fileUrl
,
&
needed
,
0
)))
if
(
FAILED
(
UrlCreateFromPathW
(
fullpath
,
fileUrl
,
&
needed
,
0
)))
{
ERR
(
"can't create url from path
\n
"
);
return
E_FAIL
;
...
...
@@ -267,7 +267,22 @@ HRESULT create_moniker_from_url(LPCWSTR url, IMoniker **mon)
url
=
fileUrl
;
}
return
CreateURLMonikerEx
(
NULL
,
url
,
mon
,
0
);
return
CreateUri
(
url
,
Uri_CREATE_ALLOW_RELATIVE
|
Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
,
0
,
uri
);
}
HRESULT
create_moniker_from_url
(
LPCWSTR
url
,
IMoniker
**
mon
)
{
HRESULT
hr
;
IUri
*
uri
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
url
));
if
(
FAILED
(
hr
=
create_uri
(
url
,
&
uri
)))
return
hr
;
hr
=
CreateURLMonikerEx2
(
NULL
,
uri
,
mon
,
0
);
IUri_Release
(
uri
);
return
hr
;
}
HRESULT
bind_url
(
IMoniker
*
mon
,
HRESULT
(
*
onDataAvailable
)(
void
*
,
char
*
,
DWORD
),
...
...
dlls/msxml3/domdoc.c
View file @
cdaf5625
...
...
@@ -86,7 +86,7 @@ typedef struct {
xmlChar
const
*
selectNsStr
;
LONG
selectNsStr_len
;
BOOL
XPath
;
WCHAR
*
url
;
IUri
*
uri
;
}
domdoc_properties
;
typedef
struct
ConnectionPoint
ConnectionPoint
;
...
...
@@ -298,8 +298,8 @@ static domdoc_properties *create_properties(MSXML_VERSION version)
properties
->
version
=
version
;
properties
->
XPath
=
(
version
==
MSXML4
||
version
==
MSXML6
);
/* document ur
l
*/
properties
->
ur
l
=
NULL
;
/* document ur
i
*/
properties
->
ur
i
=
NULL
;
return
properties
;
}
...
...
@@ -335,16 +335,9 @@ static domdoc_properties* copy_properties(domdoc_properties const* properties)
list_add_tail
(
&
pcopy
->
selectNsList
,
&
new_ns
->
entry
);
}
if
(
properties
->
url
)
{
int
len
=
strlenW
(
properties
->
url
);
pcopy
->
url
=
CoTaskMemAlloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
pcopy
->
url
,
properties
->
url
,
len
*
sizeof
(
WCHAR
));
pcopy
->
url
[
len
]
=
0
;
}
else
pcopy
->
url
=
NULL
;
pcopy
->
uri
=
properties
->
uri
;
if
(
pcopy
->
uri
)
IUri_AddRef
(
pcopy
->
uri
);
}
return
pcopy
;
...
...
@@ -358,7 +351,8 @@ static void free_properties(domdoc_properties* properties)
IXMLDOMSchemaCollection2_Release
(
properties
->
schemaCache
);
clear_selectNsList
(
&
properties
->
selectNsList
);
heap_free
((
xmlChar
*
)
properties
->
selectNsStr
);
CoTaskMemFree
(
properties
->
url
);
if
(
properties
->
uri
)
IUri_Release
(
properties
->
uri
);
heap_free
(
properties
);
}
}
...
...
@@ -2293,16 +2287,20 @@ static HRESULT WINAPI domdoc_load(
if
(
filename
)
{
IMoniker
*
mon
;
IUri
*
uri
;
CoTaskMemFree
(
This
->
properties
->
url
);
This
->
properties
->
url
=
NULL
;
if
(
This
->
properties
->
uri
)
{
IUri_Release
(
This
->
properties
->
uri
);
This
->
properties
->
uri
=
NULL
;
}
hr
=
create_moniker_from_url
(
filename
,
&
mon
);
hr
=
create_uri
(
filename
,
&
uri
);
if
(
SUCCEEDED
(
hr
))
hr
=
CreateURLMonikerEx2
(
NULL
,
uri
,
&
mon
,
0
);
if
(
SUCCEEDED
(
hr
)
)
{
hr
=
domdoc_load_moniker
(
This
,
mon
);
if
(
hr
==
S_OK
)
IMoniker_GetDisplayName
(
mon
,
NULL
,
NULL
,
&
This
->
properties
->
url
);
IMoniker_Release
(
mon
);
}
...
...
@@ -2310,6 +2308,7 @@ static HRESULT WINAPI domdoc_load(
This
->
error
=
E_FAIL
;
else
{
This
->
properties
->
uri
=
uri
;
hr
=
This
->
error
=
S_OK
;
*
isSuccessful
=
VARIANT_TRUE
;
}
...
...
@@ -2374,16 +2373,10 @@ static HRESULT WINAPI domdoc_get_url(
if
(
!
url
)
return
E_INVALIDARG
;
if
(
This
->
properties
->
url
)
{
*
url
=
SysAllocString
(
This
->
properties
->
url
);
if
(
!*
url
)
return
E_OUTOFMEMORY
;
return
S_OK
;
}
else
if
(
!
This
->
properties
->
uri
)
return
return_null_bstr
(
url
);
return
IUri_GetPropertyBSTR
(
This
->
properties
->
uri
,
Uri_PROPERTY_DISPLAY_URI
,
url
,
0
);
}
...
...
dlls/msxml3/msxml_private.h
View file @
cdaf5625
...
...
@@ -544,6 +544,7 @@ static inline const CLSID* SchemaCache_version(MSXML_VERSION v)
typedef
struct
bsc_t
bsc_t
;
HRESULT
create_moniker_from_url
(
LPCWSTR
,
IMoniker
**
)
DECLSPEC_HIDDEN
;
HRESULT
create_uri
(
const
WCHAR
*
,
IUri
**
)
DECLSPEC_HIDDEN
;
HRESULT
bind_url
(
IMoniker
*
,
HRESULT
(
*
onDataAvailable
)(
void
*
,
char
*
,
DWORD
),
void
*
,
bsc_t
**
)
DECLSPEC_HIDDEN
;
HRESULT
detach_bsc
(
bsc_t
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/msxml3/tests/domdoc.c
View file @
cdaf5625
...
...
@@ -10152,13 +10152,68 @@ static void write_to_file(const char *name, const char *data)
CloseHandle
(
hfile
);
}
static
void
test_doc_load_from_path
(
IXMLDOMDocument
*
doc
,
const
char
*
path
)
{
IXMLDOMDocument
*
doc2
;
IXMLDOMElement
*
elem
;
BSTR
url
,
url2
;
VARIANT_BOOL
b
;
VARIANT
src
;
HRESULT
hr
;
url
=
_bstr_
(
path
);
V_VT
(
&
src
)
=
VT_BSTR
;
V_BSTR
(
&
src
)
=
url
;
hr
=
IXMLDOMDocument_load
(
doc
,
src
,
&
b
);
ok
(
hr
==
S_OK
,
"Failed to load document, %#x.
\n
"
,
hr
);
ok
(
b
==
VARIANT_TRUE
,
"got %d
\n
"
,
b
);
V_VT
(
&
src
)
=
VT_BSTR
|
VT_BYREF
;
V_BSTRREF
(
&
src
)
=
&
url
;
hr
=
IXMLDOMDocument_load
(
doc
,
src
,
&
b
);
ok
(
hr
==
S_OK
,
"Failed to load document, %#x.
\n
"
,
hr
);
ok
(
b
==
VARIANT_TRUE
,
"got %d
\n
"
,
b
);
url
=
NULL
;
hr
=
IXMLDOMDocument_get_url
(
doc
,
&
url
);
ok
(
hr
==
S_OK
,
"Failed to get document url, hr %#x.
\n
"
,
hr
);
hr
=
IXMLDOMDocument_get_documentElement
(
doc
,
&
elem
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
/* Create another instance for the same document, check url */
hr
=
IXMLDOMElement_get_ownerDocument
(
elem
,
&
doc2
);
ok
(
hr
==
S_OK
,
"Failed to get owner document, hr %#x.
\n
"
,
hr
);
hr
=
IXMLDOMDocument_get_url
(
doc2
,
&
url2
);
ok
(
hr
==
S_OK
,
"Failed to get document url, hr %#x.
\n
"
,
hr
);
ok
(
!
lstrcmpW
(
url
,
url2
),
"Unexpected url %s.
\n
"
,
wine_dbgstr_w
(
url2
));
IXMLDOMDocument_Release
(
doc2
);
IXMLDOMElement_Release
(
elem
);
SysFreeString
(
url2
);
SysFreeString
(
url
);
}
static
void
url_forward_slash
(
char
*
url
)
{
char
*
p
=
url
;
while
(
*
p
)
{
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
p
++
;
}
}
static
void
test_load
(
void
)
{
IXMLDOMDocument
*
doc
,
*
doc2
;
BSTR
pathW
,
bstr1
,
bstr2
;
char
path
[
MAX_PATH
],
path2
[
MAX_PATH
];
IXMLDOMNodeList
*
list
;
IXMLDOM
Element
*
elem
;
char
path
[
MAX_PATH
]
;
IXMLDOM
Document
*
doc
;
BSTR
bstr1
,
bstr2
;
VARIANT_BOOL
b
;
VARIANT
src
;
HRESULT
hr
;
...
...
@@ -10179,47 +10234,26 @@ static void test_load(void)
EXPECT_HR
(
hr
,
E_INVALIDARG
);
ok
(
b
==
VARIANT_FALSE
,
"got %d
\n
"
,
b
);
pathW
=
_bstr_
(
path
);
/* load from path: VT_BSTR */
V_VT
(
&
src
)
=
VT_BSTR
;
V_BSTR
(
&
src
)
=
pathW
;
hr
=
IXMLDOMDocument_load
(
doc
,
src
,
&
b
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
b
==
VARIANT_TRUE
,
"got %d
\n
"
,
b
);
bstr1
=
NULL
;
hr
=
IXMLDOMDocument_get_url
(
doc
,
&
bstr1
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
SysFreeString
(
bstr1
);
/* load from a path: VT_BSTR|VT_BYREF */
V_VT
(
&
src
)
=
VT_BSTR
|
VT_BYREF
;
V_BSTRREF
(
&
src
)
=
&
pathW
;
hr
=
IXMLDOMDocument_load
(
doc
,
src
,
&
b
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
b
==
VARIANT_TRUE
,
"got %d
\n
"
,
b
);
bstr1
=
NULL
;
hr
=
IXMLDOMDocument_get_url
(
doc
,
&
bstr1
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXMLDOMDocument_get_documentElement
(
doc
,
&
elem
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
/* "file://" url */
strcpy
(
path2
,
"file://"
);
strcat
(
path2
,
path
);
test_doc_load_from_path
(
doc
,
path2
);
/*
create another instance for the same document, check url
*/
hr
=
IXMLDOMElement_get_ownerDocument
(
elem
,
&
doc
2
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
/*
file:// url, forward slashes
*/
url_forward_slash
(
path
2
);
test_doc_load_from_path
(
doc
,
path2
);
hr
=
IXMLDOMDocument_get_url
(
doc
,
&
bstr2
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
!
lstrcmpW
(
bstr1
,
bstr2
),
"got %s
\n
"
,
wine_dbgstr_w
(
bstr2
));
/* "file:/" url */
strcpy
(
path2
,
"file:/"
);
strcat
(
path2
,
path
);
test_doc_load_from_path
(
doc
,
path
);
IXMLDOMDocument_Release
(
doc2
);
IXMLDOMElement_Release
(
elem
);
/* file:/ with forward slashes. */
url_forward_slash
(
path2
);
test_doc_load_from_path
(
doc
,
path2
);
SysFreeString
(
bstr1
);
SysFreeString
(
bstr2
);
/* Regular local path. */
test_doc_load_from_path
(
doc
,
path
);
/* load from a path: VT_BSTR|VT_BYREF, null ptr */
V_VT
(
&
src
)
=
VT_BSTR
|
VT_BYREF
;
...
...
@@ -10239,7 +10273,7 @@ static void test_load(void)
write_to_file
(
path
,
nocontent
);
V_VT
(
&
src
)
=
VT_BSTR
;
V_BSTR
(
&
src
)
=
pathW
;
V_BSTR
(
&
src
)
=
_bstr_
(
path
)
;
b
=
VARIANT_TRUE
;
hr
=
IXMLDOMDocument_load
(
doc
,
src
,
&
b
);
ok
(
hr
==
S_FALSE
,
"got 0x%08x
\n
"
,
hr
);
...
...
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