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
51d40d82
Commit
51d40d82
authored
Sep 02, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Sep 02, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added JSGlobal_unescape implementation.
parent
2e97b1f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
2 deletions
+87
-2
global.c
dlls/jscript/global.c
+76
-2
api.js
dlls/jscript/tests/api.js
+11
-0
No files found.
dlls/jscript/global.c
View file @
51d40d82
...
...
@@ -576,11 +576,85 @@ static HRESULT JSGlobal_parseFloat(DispatchEx *dispex, LCID lcid, WORD flags, DI
return
S_OK
;
}
static
inline
int
hex_to_int
(
const
WCHAR
wch
)
{
if
(
toupperW
(
wch
)
>=
'A'
&&
toupperW
(
wch
)
<=
'F'
)
return
toupperW
(
wch
)
-
'A'
+
10
;
if
(
isdigitW
(
wch
))
return
wch
-
'0'
;
return
-
1
;
}
static
HRESULT
JSGlobal_unescape
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
FIXME
(
"
\n
"
);
return
E_NOTIMPL
;
BSTR
ret
,
str
;
const
WCHAR
*
ptr
;
DWORD
len
=
0
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
if
(
!
arg_cnt
(
dp
))
{
if
(
retv
)
{
ret
=
SysAllocString
(
undefinedW
);
if
(
!
ret
)
return
E_OUTOFMEMORY
;
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
ret
;
}
return
S_OK
;
}
hres
=
to_string
(
dispex
->
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
str
);
if
(
FAILED
(
hres
))
return
hres
;
for
(
ptr
=
str
;
*
ptr
;
ptr
++
)
{
if
(
*
ptr
==
'%'
)
{
if
(
hex_to_int
(
*
(
ptr
+
1
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
2
))
!=-
1
)
ptr
+=
2
;
else
if
(
*
(
ptr
+
1
)
==
'u'
&&
hex_to_int
(
*
(
ptr
+
2
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
3
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
4
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
5
))
!=-
1
)
ptr
+=
5
;
}
len
++
;
}
ret
=
SysAllocStringLen
(
NULL
,
len
);
if
(
!
ret
)
return
E_OUTOFMEMORY
;
len
=
0
;
for
(
ptr
=
str
;
*
ptr
;
ptr
++
)
{
if
(
*
ptr
==
'%'
)
{
if
(
hex_to_int
(
*
(
ptr
+
1
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
2
))
!=-
1
)
{
ret
[
len
]
=
(
hex_to_int
(
*
(
ptr
+
1
))
<<
4
)
+
hex_to_int
(
*
(
ptr
+
2
));
ptr
+=
2
;
}
else
if
(
*
(
ptr
+
1
)
==
'u'
&&
hex_to_int
(
*
(
ptr
+
2
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
3
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
4
))
!=-
1
&&
hex_to_int
(
*
(
ptr
+
5
))
!=-
1
)
{
ret
[
len
]
=
(
hex_to_int
(
*
(
ptr
+
2
))
<<
12
)
+
(
hex_to_int
(
*
(
ptr
+
3
))
<<
8
)
+
(
hex_to_int
(
*
(
ptr
+
4
))
<<
4
)
+
hex_to_int
(
*
(
ptr
+
5
));
ptr
+=
5
;
}
else
ret
[
len
]
=
*
ptr
;
}
else
ret
[
len
]
=
*
ptr
;
len
++
;
}
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
ret
;
}
else
SysFreeString
(
ret
);
return
S_OK
;
}
static
HRESULT
JSGlobal_GetObject
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
51d40d82
...
...
@@ -58,6 +58,17 @@ ok(tmp === "undefined", "encodeURI() = " + tmp);
tmp
=
encodeURI
(
"abc"
,
"test"
);
ok
(
tmp
===
"abc"
,
"encodeURI('abc') = "
+
tmp
);
tmp
=
unescape
(
"abc"
);
ok
(
tmp
===
"abc"
,
"unescape('abc') = "
+
tmp
);
tmp
=
unescape
(
""
);
ok
(
tmp
===
""
,
"unescape('') = "
+
tmp
);
tmp
=
unescape
(
"%%%"
);
ok
(
tmp
===
"%%%"
,
"unescape('%%%') = "
+
tmp
);
tmp
=
unescape
();
ok
(
tmp
===
"undefined"
,
"unescape() = "
+
tmp
);
tmp
=
unescape
(
"%54%65s%u0074"
);
ok
(
tmp
===
"Test"
,
"unescape('%54%65s%u0074') = "
+
tmp
);
tmp
=
""
+
new
Object
();
ok
(
tmp
===
"[object Object]"
,
"'' + new Object() = "
+
tmp
);
(
tmp
=
new
Array
).
f
=
Object
.
prototype
.
toString
;
...
...
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