Lightpanda: the headless browser designed for AI and automation
reset arena after use, verify user input
Karl Seguin63a42839890b
diff --git a/src/cdp/CDP.zig b/src/cdp/CDP.zigindex 660096936..8aa2d3aa3 100644--- a/src/cdp/CDP.zig+++ b/src/cdp/CDP.zig@@ -1008,11 +1008,13 @@ pub const BrowserContext = struct {try self.captured_requests.put(self.frame_arena, key, owned_body);}}+ defer self.resetNotificationArena();try @import("domains/network.zig").httpRequestStart(self.notification_arena, self, msg);}pub fn onHttpRequestIntercept(ctx: *anyopaque, msg: *const Notification.RequestIntercept) !void {const self: *BrowserContext = @ptrCast(@alignCast(ctx));+ defer self.resetNotificationArena();try @import("domains/fetch.zig").requestIntercept(self.notification_arena, self, msg);}@@ -1089,7 +1091,7 @@ pub const BrowserContext = struct {const key = keyFromTransfer(msg.transfer);const resp = self.captured_responses.getPtr(key) orelse lp.assert(false, "onHttpResponseData missing captured response", .{});- return resp.data.appendSlice(arena, msg.data);+ return resp.data.appendSliceAssumeCapacitySlice(arena, msg.data);}pub fn onHttpRequestAuthRequired(ctx: *anyopaque, data: *const Notification.RequestAuthRequired) !void {diff --git a/src/cdp/domains/network.zig b/src/cdp/domains/network.zigindex dce037291..d8e334ac9 100644--- a/src/cdp/domains/network.zig+++ b/src/cdp/domains/network.zig@@ -659,6 +659,10 @@ fn securityState(url: [:0]const u8) []const u8 {}fn keyFromRequestId(request_id: []const u8) !CDP.BrowserContext.CapturedKey {+ if (request_id.len < 4) {+ return error.InvalidParams;+ }+const key = std.fmt.parseInt(u32, request_id[4..], 10) catch return error.InvalidParams;return if (std.mem.startsWith(u8, request_id, "LID-"))