Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(browser): report zero decoded bytes for undecodable gRPC-web text (#6159)

Abel Yagubyand54c4345d3fb
diff --git a/src/browser/history/protobuf/ProtobufBody.ts b/src/browser/history/protobuf/ProtobufBody.ts
index eb3d91777..7cf567406 100644
--- a/src/browser/history/protobuf/ProtobufBody.ts
+++ b/src/browser/history/protobuf/ProtobufBody.ts
@@ -47,7 +47,7 @@ export const decodeProtobufBody = async (
framing,
offset_basis:
framing === "grpc-web-text" ? "base64-decoded-body" : "retained-body",
- decoded_bytes: body.length,
+ decoded_bytes: 0,
status: "complete",
examined_bytes: 0,
frames: [],
diff --git a/src/browser/history/protobuf/ProtobufWire.test.ts b/src/browser/history/protobuf/ProtobufWire.test.ts
index 1c7c6eb06..3afe274b7 100644
--- a/src/browser/history/protobuf/ProtobufWire.test.ts
+++ b/src/browser/history/protobuf/ProtobufWire.test.ts
@@ -247,17 +247,23 @@ it("decodes independently padded base64 chunks with explicit coordinates and rej
["offset:12", "2"],
]);
expect(decoded.fields.map(({ index }) => index)).toEqual([0, 1]);
- expect(
- (
+ for (const text of ["AB==", "!!!!", first.toString("base64") + "AB=="])
+ expect(
await decodeProtobufBody(
- Buffer.from("AB=="),
+ Buffer.from(text),
"grpc-web-text",
source,
same,
new ProtobufBudget(),
- )
- ).status,
- ).toBe("partial");
+ ),
+ ).toMatchObject({
+ decoded_bytes: 0,
+ status: "partial",
+ examined_bytes: 0,
+ frames: [],
+ fields: [],
+ error: { offset: 0 },
+ });
});
it("keeps compressed payloads explicitly unknown and rejects frames beyond the body", async () => {