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
9a5ad302
Commit
9a5ad302
authored
Dec 01, 2011
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Support ICU_ESCAPE in WinHttpCrackUrl.
parent
9a2f3cb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
59 deletions
+114
-59
url.c
dlls/winhttp/tests/url.c
+24
-0
url.c
dlls/winhttp/url.c
+90
-59
No files found.
dlls/winhttp/tests/url.c
View file @
9a5ad302
...
@@ -69,6 +69,8 @@ static const WCHAR url12[] =
...
@@ -69,6 +69,8 @@ static const WCHAR url12[] =
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'e'
,
'x'
,
'a'
,
'm'
,
'p'
,
'l'
,
'e'
,
'.'
,
'n'
,
'e'
,
't'
,
'/'
,
'p'
,
'a'
,
't'
,
'h'
,
'?'
,
'v'
,
'a'
,
'r'
,
'1'
,
'='
,
'e'
,
'x'
,
'a'
,
'm'
,
'p'
,
'l'
,
'e'
,
'@'
,
'e'
,
'x'
,
'a'
,
'm'
,
'p'
,
'l'
,
'e'
,
'.'
,
'c'
,
'o'
,
'm'
,
'&'
,
'v'
,
'a'
,
'r'
,
'2'
,
'='
,
'x'
,
'&'
,
'v'
,
'a'
,
'r'
,
'3'
,
'='
,
'y'
,
0
};
{
'h'
,
't'
,
't'
,
'p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'
,
'e'
,
'z'
,
'M'
,
0
};
static
const
WCHAR
url14
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
' '
,
'g'
,
'/'
,
'p'
,
'a'
,
't'
,
'h'
,
' '
,
'w'
,
'i'
,
't'
,
'h'
,
' '
,
's'
,
'p'
,
'a'
,
'c'
,
'e'
,
's'
,
0
};
static
const
WCHAR
url_k1
[]
=
static
const
WCHAR
url_k1
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'u'
,
's'
,
'e'
,
'r'
,
'n'
,
'a'
,
'm'
,
'e'
,
':'
,
'p'
,
'a'
,
's'
,
's'
,
'w'
,
'o'
,
'r'
,
'd'
,
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'u'
,
's'
,
'e'
,
'r'
,
'n'
,
'a'
,
'm'
,
'e'
,
':'
,
'p'
,
'a'
,
's'
,
's'
,
'w'
,
'o'
,
'r'
,
'd'
,
...
@@ -318,6 +320,10 @@ static void reset_url_components( URL_COMPONENTS *uc )
...
@@ -318,6 +320,10 @@ static void reset_url_components( URL_COMPONENTS *uc )
static
void
WinHttpCrackUrl_test
(
void
)
static
void
WinHttpCrackUrl_test
(
void
)
{
{
static
const
WCHAR
hostnameW
[]
=
{
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
' '
,
'g'
,
0
};
static
const
WCHAR
pathW
[]
=
{
'/'
,
'p'
,
'a'
,
't'
,
'h'
,
'%'
,
'2'
,
'0'
,
'w'
,
'i'
,
't'
,
'h'
,
'%'
,
'2'
,
'0'
,
's'
,
'p'
,
'a'
,
'c'
,
'e'
,
's'
,
0
};
URL_COMPONENTSW
uc
;
URL_COMPONENTSW
uc
;
WCHAR
scheme
[
20
],
user
[
20
],
pass
[
20
],
host
[
20
],
path
[
80
],
extra
[
40
];
WCHAR
scheme
[
20
],
user
[
20
],
pass
[
20
],
host
[
20
],
path
[
80
],
extra
[
40
];
DWORD
error
;
DWORD
error
;
...
@@ -599,6 +605,24 @@ static void WinHttpCrackUrl_test( void )
...
@@ -599,6 +605,24 @@ static void WinHttpCrackUrl_test( void )
uc
.
nPort
=
0
;
uc
.
nPort
=
0
;
ret
=
WinHttpCrackUrl
(
url13
,
0
,
ICU_DECODE
,
&
uc
);
ret
=
WinHttpCrackUrl
(
url13
,
0
,
ICU_DECODE
,
&
uc
);
ok
(
ret
,
"WinHttpCrackUrl failed
\n
"
);
ok
(
ret
,
"WinHttpCrackUrl failed
\n
"
);
uc
.
lpszScheme
=
scheme
;
uc
.
dwSchemeLength
=
20
;
uc
.
lpszHostName
=
host
;
uc
.
dwHostNameLength
=
20
;
uc
.
lpszUserName
=
NULL
;
uc
.
dwUserNameLength
=
0
;
uc
.
lpszPassword
=
NULL
;
uc
.
dwPasswordLength
=
0
;
uc
.
lpszUrlPath
=
path
;
uc
.
dwUrlPathLength
=
40
;
uc
.
lpszExtraInfo
=
NULL
;
uc
.
dwExtraInfoLength
=
0
;
uc
.
nPort
=
0
;
ret
=
WinHttpCrackUrl
(
url14
,
0
,
ICU_ESCAPE
|
ICU_DECODE
,
&
uc
);
ok
(
ret
,
"WinHttpCrackUrl failed
\n
"
);
ok
(
!
lstrcmpW
(
uc
.
lpszHostName
,
hostnameW
),
"unexpected host name
\n
"
);
ok
(
!
lstrcmpW
(
uc
.
lpszUrlPath
,
pathW
),
"unexpected path
\n
"
);
}
}
START_TEST
(
url
)
START_TEST
(
url
)
...
...
dlls/winhttp/url.c
View file @
9a5ad302
...
@@ -38,7 +38,7 @@ static BOOL set_component( WCHAR **str, DWORD *str_len, WCHAR *value, DWORD len,
...
@@ -38,7 +38,7 @@ static BOOL set_component( WCHAR **str, DWORD *str_len, WCHAR *value, DWORD len,
{
{
if
(
!*
str
)
if
(
!*
str
)
{
{
if
(
len
&&
*
str_len
&&
(
flags
&
ICU_DECODE
))
if
(
len
&&
*
str_len
&&
(
flags
&
(
ICU_DECODE
|
ICU_ESCAPE
)
))
{
{
set_last_error
(
ERROR_INVALID_PARAMETER
);
set_last_error
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
...
@@ -89,18 +89,93 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
...
@@ -89,18 +89,93 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
return
ret
;
return
ret
;
}
}
static
BOOL
need_escape
(
WCHAR
c
)
{
if
(
isalnumW
(
c
))
return
FALSE
;
if
(
c
<=
31
||
c
>=
127
)
return
TRUE
;
else
{
switch
(
c
)
{
case
' '
:
case
'"'
:
case
'#'
:
case
'%'
:
case
'<'
:
case
'>'
:
case
']'
:
case
'\\'
:
case
'['
:
case
'^'
:
case
'`'
:
case
'{'
:
case
'|'
:
case
'}'
:
case
'~'
:
return
TRUE
;
default:
return
FALSE
;
}
}
}
static
DWORD
copy_escape
(
WCHAR
*
dst
,
const
WCHAR
*
src
,
DWORD
len
)
{
static
const
WCHAR
hex
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
DWORD
ret
=
len
;
unsigned
int
i
;
WCHAR
*
p
=
dst
;
for
(
i
=
0
;
i
<
len
;
i
++
,
p
++
)
{
if
(
need_escape
(
src
[
i
]
))
{
p
[
0
]
=
'%'
;
p
[
1
]
=
hex
[(
src
[
i
]
>>
4
)
&
0xf
];
p
[
2
]
=
hex
[
src
[
i
]
&
0xf
];
ret
+=
2
;
p
+=
2
;
}
else
*
p
=
src
[
i
];
}
dst
[
ret
]
=
0
;
return
ret
;
}
static
WCHAR
*
escape_url
(
LPCWSTR
url
,
DWORD
*
len
)
{
WCHAR
*
ret
;
const
WCHAR
*
p
,
*
q
;
if
((
p
=
q
=
strrchrW
(
url
,
'/'
)))
{
while
(
*
q
)
{
if
(
need_escape
(
*
q
))
*
len
+=
2
;
q
++
;
}
}
if
(
!
(
ret
=
heap_alloc
(
(
*
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
p
)
strcpyW
(
ret
,
url
);
else
{
memcpy
(
ret
,
url
,
(
p
-
url
)
*
sizeof
(
WCHAR
)
);
copy_escape
(
ret
+
(
p
-
url
),
p
,
q
-
p
);
}
return
ret
;
}
/***********************************************************************
/***********************************************************************
* WinHttpCrackUrl (winhttp.@)
* WinHttpCrackUrl (winhttp.@)
*/
*/
BOOL
WINAPI
WinHttpCrackUrl
(
LPCWSTR
url
,
DWORD
len
,
DWORD
flags
,
LPURL_COMPONENTSW
uc
)
BOOL
WINAPI
WinHttpCrackUrl
(
LPCWSTR
url
,
DWORD
len
,
DWORD
flags
,
LPURL_COMPONENTSW
uc
)
{
{
BOOL
ret
=
FALSE
;
BOOL
ret
=
FALSE
;
WCHAR
*
p
,
*
q
,
*
r
,
*
url_decoded
=
NULL
;
WCHAR
*
p
,
*
q
,
*
r
,
*
url_decoded
=
NULL
,
*
url_escaped
=
NULL
;
TRACE
(
"%s, %d, %x, %p
\n
"
,
debugstr_w
(
url
),
len
,
flags
,
uc
);
TRACE
(
"%s, %d, %x, %p
\n
"
,
debugstr_w
(
url
),
len
,
flags
,
uc
);
if
(
flags
&
ICU_ESCAPE
)
FIXME
(
"flag ICU_ESCAPE not supported
\n
"
);
if
(
!
url
||
!
uc
||
uc
->
dwStructSize
!=
sizeof
(
URL_COMPONENTS
))
if
(
!
url
||
!
uc
||
uc
->
dwStructSize
!=
sizeof
(
URL_COMPONENTS
))
{
{
set_last_error
(
ERROR_INVALID_PARAMETER
);
set_last_error
(
ERROR_INVALID_PARAMETER
);
...
@@ -108,7 +183,16 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
...
@@ -108,7 +183,16 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
}
}
if
(
!
len
)
len
=
strlenW
(
url
);
if
(
!
len
)
len
=
strlenW
(
url
);
if
(
flags
&
ICU_DECODE
)
if
(
flags
&
ICU_ESCAPE
)
{
if
(
!
(
url_escaped
=
escape_url
(
url
,
&
len
)))
{
set_last_error
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
url
=
url_escaped
;
}
else
if
(
flags
&
ICU_DECODE
)
{
{
if
(
!
(
url_decoded
=
decode_url
(
url
,
&
len
)))
if
(
!
(
url_decoded
=
decode_url
(
url
,
&
len
)))
{
{
...
@@ -211,6 +295,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
...
@@ -211,6 +295,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
exit:
exit:
heap_free
(
url_decoded
);
heap_free
(
url_decoded
);
heap_free
(
url_escaped
);
return
ret
;
return
ret
;
}
}
...
@@ -235,60 +320,6 @@ static BOOL uses_default_port( INTERNET_SCHEME scheme, INTERNET_PORT port )
...
@@ -235,60 +320,6 @@ static BOOL uses_default_port( INTERNET_SCHEME scheme, INTERNET_PORT port )
return
FALSE
;
return
FALSE
;
}
}
static
BOOL
need_escape
(
WCHAR
c
)
{
if
(
isalnumW
(
c
))
return
FALSE
;
if
(
c
<=
31
||
c
>=
127
)
return
TRUE
;
else
{
switch
(
c
)
{
case
' '
:
case
'"'
:
case
'#'
:
case
'%'
:
case
'<'
:
case
'>'
:
case
']'
:
case
'\\'
:
case
'['
:
case
'^'
:
case
'`'
:
case
'{'
:
case
'|'
:
case
'}'
:
case
'~'
:
return
TRUE
;
default:
return
FALSE
;
}
}
}
static
DWORD
copy_escape
(
WCHAR
*
dst
,
const
WCHAR
*
src
,
DWORD
len
)
{
static
const
WCHAR
hex
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
DWORD
ret
=
len
;
unsigned
int
i
;
WCHAR
*
p
=
dst
;
for
(
i
=
0
;
i
<
len
;
i
++
,
p
++
)
{
if
(
need_escape
(
src
[
i
]
))
{
p
[
0
]
=
'%'
;
p
[
1
]
=
hex
[(
src
[
i
]
>>
4
)
&
0xf
];
p
[
2
]
=
hex
[
src
[
i
]
&
0xf
];
ret
+=
2
;
p
+=
2
;
}
else
*
p
=
src
[
i
];
}
dst
[
ret
]
=
0
;
return
ret
;
}
static
DWORD
comp_length
(
DWORD
len
,
DWORD
flags
,
WCHAR
*
comp
)
static
DWORD
comp_length
(
DWORD
len
,
DWORD
flags
,
WCHAR
*
comp
)
{
{
DWORD
ret
;
DWORD
ret
;
...
...
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