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
de0a8751
Commit
de0a8751
authored
Oct 06, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Oct 06, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added Global.escape() implementation.
parent
be910d97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
2 deletions
+79
-2
global.c
dlls/jscript/global.c
+66
-2
api.js
dlls/jscript/tests/api.js
+13
-0
No files found.
dlls/jscript/global.c
View file @
de0a8751
...
...
@@ -296,8 +296,72 @@ static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
static
HRESULT
JSGlobal_escape
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
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
,
i
,
size
;
char
buf
[
4
];
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
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
str
);
if
(
FAILED
(
hres
))
return
hres
;
for
(
ptr
=
str
;
*
ptr
;
ptr
++
)
{
if
(
isalnumW
(
*
ptr
)
||
*
ptr
==
'*'
||
*
ptr
==
'@'
||
*
ptr
==
'-'
||
*
ptr
==
'_'
||
*
ptr
==
'+'
||
*
ptr
==
'.'
||
*
ptr
==
'/'
)
len
++
;
else
{
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
ptr
,
1
,
NULL
,
0
,
NULL
,
NULL
)
*
3
;
if
(
!
size
)
{
FIXME
(
"throw Error
\n
"
);
return
E_FAIL
;
}
len
+=
size
;
}
}
ret
=
SysAllocStringLen
(
NULL
,
len
);
if
(
!
ret
)
return
E_OUTOFMEMORY
;
len
=
0
;
for
(
ptr
=
str
;
*
ptr
;
ptr
++
)
{
if
(
isalnumW
(
*
ptr
)
||
*
ptr
==
'*'
||
*
ptr
==
'@'
||
*
ptr
==
'-'
||
*
ptr
==
'_'
||
*
ptr
==
'+'
||
*
ptr
==
'.'
||
*
ptr
==
'/'
)
ret
[
len
++
]
=
*
ptr
;
else
{
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
ptr
,
1
,
buf
,
sizeof
(
buf
),
NULL
,
NULL
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
ret
[
len
++
]
=
'%'
;
ret
[
len
++
]
=
int_to_char
(
buf
[
i
]
>>
4
);
ret
[
len
++
]
=
int_to_char
(
buf
[
i
]
&
0xf
);
}
}
}
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
ret
;
}
else
SysFreeString
(
ret
);
return
S_OK
;
}
/* ECMA-262 3rd Edition 15.1.2.1 */
...
...
dlls/jscript/tests/api.js
View file @
de0a8751
...
...
@@ -58,6 +58,15 @@ ok(tmp === "undefined", "encodeURI() = " + tmp);
tmp
=
encodeURI
(
"abc"
,
"test"
);
ok
(
tmp
===
"abc"
,
"encodeURI('abc') = "
+
tmp
);
tmp
=
escape
(
"abc"
);
ok
(
tmp
===
"abc"
,
"escape('abc') = "
+
tmp
);
tmp
=
escape
(
""
);
ok
(
tmp
===
""
,
"escape('') = "
+
tmp
);
tmp
=
escape
(
"a1b c!d+e@*-_+./,"
);
ok
(
tmp
===
"a1b%20c%21d+e@*-_+./%2C"
,
"escape('a1b c!d+e@*-_+./,') = "
+
tmp
);
tmp
=
escape
();
ok
(
tmp
===
"undefined"
,
"escape() = "
+
tmp
);
tmp
=
unescape
(
"abc"
);
ok
(
tmp
===
"abc"
,
"unescape('abc') = "
+
tmp
);
tmp
=
unescape
(
""
);
...
...
@@ -69,6 +78,10 @@ ok(tmp === "undefined", "unescape() = " + tmp);
tmp
=
unescape
(
"%54%65s%u0074"
);
ok
(
tmp
===
"Test"
,
"unescape('%54%65s%u0074') = "
+
tmp
);
tmp
=
"aA1~`!@#$%^&*()_+=-][{}';:/.,<>?
\
|"
;
ok
(
escape
(
tmp
)
===
"aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C"
,
"escape('"
+
tmp
+
"') = "
+
escape
(
tmp
));
ok
(
unescape
(
escape
(
tmp
))
===
tmp
,
"unescape(escape('"
+
tmp
+
"')) = "
+
unescape
(
escape
(
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