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
627e5b3b
Commit
627e5b3b
authored
May 29, 2023
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
May 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Return undefined for empty RegExp captures in ES5+ mode.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
ce453e42
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
7 deletions
+40
-7
jsregexp.c
dlls/jscript/jsregexp.c
+12
-7
regexp.js
dlls/jscript/tests/regexp.js
+12
-0
es5.js
dlls/mshtml/tests/es5.js
+16
-0
No files found.
dlls/jscript/jsregexp.c
View file @
627e5b3b
...
...
@@ -361,17 +361,22 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str,
return
hres
;
for
(
i
=
0
;
i
<
result
->
paren_count
;
i
++
)
{
if
(
result
->
parens
[
i
].
index
!=
-
1
)
str
=
jsstr_substr
(
input_str
,
result
->
parens
[
i
].
index
,
result
->
parens
[
i
].
length
);
else
str
=
jsstr_empty
();
if
(
!
str
)
{
jsval_t
val
;
if
(
result
->
parens
[
i
].
index
!=
-
1
)
{
if
(
!
(
str
=
jsstr_substr
(
input_str
,
result
->
parens
[
i
].
index
,
result
->
parens
[
i
].
length
)))
{
hres
=
E_OUTOFMEMORY
;
break
;
}
val
=
jsval_string
(
str
);
}
else
if
(
ctx
->
version
<
SCRIPTLANGUAGEVERSION_ES5
)
{
val
=
jsval_string
(
jsstr_empty
());
}
else
{
val
=
jsval_undefined
();
}
hres
=
jsdisp_propput_idx
(
array
,
i
+
1
,
jsval_string
(
str
)
);
js
str_release
(
str
);
hres
=
jsdisp_propput_idx
(
array
,
i
+
1
,
val
);
js
val_release
(
val
);
if
(
FAILED
(
hres
))
break
;
}
...
...
dlls/jscript/tests/regexp.js
View file @
627e5b3b
...
...
@@ -625,6 +625,18 @@ ok(tmp === "x*y", '"x/y".replace(/[/]/, "*") = ' + tmp);
tmp
=
"x/y"
.
replace
(
/
[
xy
/]
/g
,
"*"
);
ok
(
tmp
===
"***"
,
'"x/y".replace(/[xy/]/, "*") = '
+
tmp
);
tmp
=
/
()
/
.
exec
(
""
)[
1
];
ok
(
tmp
===
""
,
"/()/ captured: "
+
tmp
);
tmp
=
/
()?
/
.
exec
(
""
)[
1
];
ok
(
tmp
===
""
,
"/()?/ captured: "
+
tmp
);
tmp
=
/
()??
/
.
exec
(
""
)[
1
];
ok
(
tmp
===
""
,
"/()??/ captured: "
+
tmp
);
tmp
=
/
()
*/
.
exec
(
""
)[
1
];
ok
(
tmp
===
""
,
"/()*/ captured: "
+
tmp
);
tmp
=
/
()??()
/
.
exec
(
""
);
ok
(
tmp
[
1
]
===
""
,
"/()??()/ [1] captured: "
+
tmp
);
ok
(
tmp
[
2
]
===
""
,
"/()??()/ [2] captured: "
+
tmp
);
/
(
b
)
/
.
exec
(
"abc"
);
ok
(
RegExp
.
$1
===
"b"
,
"RegExp.$1 = "
+
RegExp
.
$1
);
ok
(
"$2"
in
RegExp
,
"RegExp.$2 doesn't exist"
);
...
...
dlls/mshtml/tests/es5.js
View file @
627e5b3b
...
...
@@ -1610,6 +1610,22 @@ sync_test("isFrozen", function() {
}
});
sync_test
(
"RegExp"
,
function
()
{
var
r
;
r
=
/
()
/
.
exec
(
""
)[
1
];
ok
(
r
===
""
,
"/()/ captured: "
+
r
);
r
=
/
()?
/
.
exec
(
""
)[
1
];
ok
(
r
===
undefined
,
"/()?/ captured: "
+
r
);
r
=
/
()??
/
.
exec
(
""
)[
1
];
ok
(
r
===
undefined
,
"/()??/ captured: "
+
r
);
r
=
/
()
*/
.
exec
(
""
)[
1
];
ok
(
r
===
undefined
,
"/()*/ captured: "
+
r
);
r
=
/
()??()
/
.
exec
(
""
);
ok
(
r
[
1
]
===
undefined
,
"/()??()/ [1] captured: "
+
r
);
ok
(
r
[
2
]
===
""
,
"/()??()/ [2] captured: "
+
r
);
});
sync_test
(
"builtin_context"
,
function
()
{
var
nullDisp
=
external
.
nullDisp
;
var
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