fix(browser): read SAZ archives with zero-byte HTTP members (#5453)

Fiddler writes a zero-byte raw/NN_s.txt (or _c.txt) for a session that
never got that message. The decoder passed it to the HTTP parser, which
found no header/body separator and rejected the whole archive, so no
session could be read even with --record.

Report a zero-byte request or response member as null, like a missing
member, keep it in location.members, and add a per-record limitation
that says only that the stored member is empty. Non-empty malformed
members are still rejected.

Fixes #5411
This commit is contained in:
amyanger authored and GitHub committed 2026-10-22 04:08:42 +08:00
1 parent 414ad52b20
commit b0a554cc3a
4 files changed
+62 -13

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ export class NodeCaptureAdapter implements HistoricalCaptureFormatAdapter {
format === "saz"
? [
"SAZ ordinals follow first session-member occurrence in ZIP directory order, not chronology or numeric session ID.",
"HTTP fields use byte-preserving Latin-1 text; start-line separators and header delimiters are not projected. Bodies retain stored bytes without transfer/content decoding. Absent members are null, distinct from empty bodies.",
"HTTP fields use byte-preserving Latin-1 text; start-line separators and header delimiters are not projected. Bodies retain stored bytes without transfer/content decoding. Absent and zero-byte HTTP members are null, distinct from empty bodies.",
"XML preserves node order and attribute/text values, not its original byte serialization. WebSocket and gRPC members retain opaque message-file bytes, not decoded protocol events.",
"Non-session archive members are inventoried but their content is not decoded.",
]
+19 -12
View File
@@ -90,6 +90,7 @@ export const decodeSazCapture = async (
websocket: null,
grpc: null,
};
const limitations: string[] = [];
for (const entry of entries) {
const stream = await reader.open(entry);
const chunks: Buffer[] = [];
@@ -114,17 +115,23 @@ export const decodeSazCapture = async (
"SAZ member does not match its declared size.",
);
const bytes = Buffer.concat(chunks, length);
if (entry.path.endsWith("_c.txt"))
source.request = {
member: entry.path,
...decodeSazHttp(bytes, true),
};
else if (entry.path.endsWith("_s.txt"))
source.response = {
member: entry.path,
...decodeSazHttp(bytes, false),
};
else if (entry.path.endsWith("_m.xml"))
const http = entry.path.endsWith("_c.txt")
? "request"
: entry.path.endsWith("_s.txt")
? "response"
: null;
if (http !== null) {
// Fiddler stores a session without this message as a zero-byte member.
if (length === 0)
limitations.push(
`The stored ${http} member is empty (zero bytes); the ${http} is reported as null.`,
);
else
source[http] = {
member: entry.path,
...decodeSazHttp(bytes, http === "request"),
};
} else if (entry.path.endsWith("_m.xml"))
source.metadata = {
member: entry.path,
document: decodeSazMetadata(bytes),
@@ -142,7 +149,7 @@ export const decodeSazCapture = async (
members: entries.map((entry) => entry.path),
},
...projectSazRecord(source, sensitiveValues),
limitations: [],
limitations,
});
}
const container = projectSazRecord({ members: inventory }, sensitiveValues);