Skip to content

Commit 4cba5a5

Browse files
os-zhuangclaude
andauthored
fix(repo): escape raw NUL bytes that hid six source files from grep (#3127)
Six source files embedded a literal U+0000 byte as a composite-key separator instead of the `\u0000` escape. grep/ripgrep scan the whole buffer, classify such a file as binary, and silently return no matches: `grep -n saveMetaItem protocol.ts` reported nothing despite 16 hits, making a core protocol file invisible to code search and to any grep-based lint tooling. This survived review because git only scans the first 8000 bytes for a NUL, and protocol.ts carried its NUL at offset 147230 - so the file kept diffing as ordinary text while grep had already given up on it. Replace each raw NUL with `\u0000`, matching the existing convention in rest-server.ts. That form is chosen over `\0`, which becomes a legacy octal escape error if it is ever followed by a digit. The resulting strings are byte-identical, so behaviour is unchanged: getMetaItemCached still emits the same per-locale ETags as before (en-US 68f978ed / zh-CN 50289f3b / no-locale 75dad1ef), still returns 304 on a same-locale match, and still declines 304 across locales (issue #1319). No changeset: pure fix, no user-facing change. Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 774f8a2 commit 4cba5a5

6 files changed

Lines changed: 1 addition & 1 deletion

File tree

5 Bytes
Binary file not shown.
5 Bytes
Binary file not shown.

packages/metadata-protocol/src/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,7 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
30513051
// language until a hard refresh (issue #1319). Folding the resolved
30523052
// locale into the hash gives each locale a distinct validator.
30533053
const content = JSON.stringify(item);
3054-
const hash = simpleHash(request.locale ? `${request.locale}
3054+
const hash = simpleHash(request.locale ? `${request.locale}\u0000${content}` : content);
30553055
const etag = { value: hash, weak: false };
30563056

30573057
// Check If-None-Match header
Binary file not shown.
Binary file not shown.
5 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)