mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
Reject constructors called as function (i.e. without 'new')
Previously, `MessageEvent('')` would have been allowed, but invalid. This caused
problems as the receiver was the window. All such calls are now rejected.
Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/131
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
.minimum_zig_version = "0.15.2",
|
.minimum_zig_version = "0.15.2",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.v8 = .{
|
.v8 = .{
|
||||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/0d64a3d5b36ac94067df3e13fddbf715caa6f391.tar.gz",
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/5cc800f6a626d1f951ed27ad2ef579f90d121907.tar.gz",
|
||||||
.hash = "v8-0.0.0-xddH65sfBAC8o3q41YxhOms5uY2fvMzBrsgN8IeCXZgE",
|
.hash = "v8-0.0.0-xddH6_0gBABrJc5cL6-P2wGvvweTTCgWdpmClr9r-C-s",
|
||||||
},
|
},
|
||||||
//.v8 = .{ .path = "../zig-v8-fork" },
|
//.v8 = .{ .path = "../zig-v8-fork" },
|
||||||
.@"boringssl-zig" = .{
|
.@"boringssl-zig" = .{
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ pub const CallOpts = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn constructor(self: *Caller, comptime T: type, func: anytype, info: v8.FunctionCallbackInfo, comptime opts: CallOpts) void {
|
pub fn constructor(self: *Caller, comptime T: type, func: anytype, info: v8.FunctionCallbackInfo, comptime opts: CallOpts) void {
|
||||||
|
if (!info.isConstructCall()) {
|
||||||
|
self.handleError(T, @TypeOf(func), error.InvalidArgument, info, opts);
|
||||||
|
return;
|
||||||
|
}
|
||||||
self._constructor(func, info) catch |err| {
|
self._constructor(func, info) catch |err| {
|
||||||
self.handleError(T, @TypeOf(func), err, info, opts);
|
self.handleError(T, @TypeOf(func), err, info, opts);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user