fix(schema): compose portable stack-safe base64 constraints
Replace the lookahead-based pattern with separate allOf/not JSON Schema rules for quartet length, alphabet, padding and canonical pad bits. Share the runtime predicates with HAR and padded base64 parsing. Validate converted advertised leaves with the MCP SDK validator, preserve permissive versus canonical semantics, and exercise every pattern near the 32 MiB encoded-input budget in all JavaScript modes.
This commit is contained in:
1 parent
4af71a45f9
commit
0949313d8f
8 files changed
+174
-47
No files matched your search
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
||||
import { LosslessNumber } from "lossless-json";
|
||||
import { parseCaptureJson } from "./CaptureJson.js";
|
||||
import type { JsonValue } from "../../domain/jsonValue.js";
|
||||
import { CANONICAL_BASE64_PATTERN } from "../../domain/stringPatterns.js";
|
||||
import { isCanonicalBase64 } from "../../domain/stringPatterns.js";
|
||||
import {
|
||||
WEB_NETWORK_CAPTURE_LIMITS,
|
||||
type WebNetworkCapture,
|
||||
@@ -265,7 +265,7 @@ const integerLexeme = (literal: string): boolean => {
|
||||
|
||||
const decodeHarBase64 = (value: string, pointer: string): Buffer => {
|
||||
const compact = value.replace(/[\t\n\r ]/g, "");
|
||||
if (compact.length % 4 !== 0 || !CANONICAL_BASE64_PATTERN.test(compact))
|
||||
if (!isCanonicalBase64(compact))
|
||||
throw new CaptureFormatError(
|
||||
"format",
|
||||
"HAR content declares base64 but its text is not valid canonical base64 (ASCII whitespace is allowed).",
|
||||
|
||||
Reference in new issue
Block a user