Skip to content

[PR] fix: avoid repeated scheme scans in URL masking - #7393

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-20_linear-url-masking
Nov 20, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-20_linear-url-masking

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The shared URL regex restarts its scheme scan at every letter of a long unbroken non-URL run. Overlapping work blocks logging/diagnostics and anonymous-session provenance, where the complete first message is masked before its 160-character preview is selected.

Fixes #7391.

Changes

Start matching once per contiguous scheme-character run. Preserve leading numeric/punctuation characters outside the URL, then use the existing single-URL maskers unchanged. Word-glued schemes, malformed URL fallbacks, Unicode boundaries, credential stripping, local host visibility, and unconditional publish masking retain their previous output.

The new regressions exercise all three public text maskers and the actual anonymous-provenance builder. The obsolete workaround comment in the existing held-forwarding test now points to the dedicated regression.

Verification

Tested base: 1e357bf2d6632bfbd2a74ffb70ecee1af1ec7cc3 (0.1.216), Linux, Node 24.22.3.

  • Unchanged production: 4 bounded-execution failures, 8 passing controls. Each failure is the actual call exceeding a two-second VM deadline.
  • Fixed production: 56/56 targeted tests pass, including real loopback anonymous-proxy requests, host-log output, published storage diagnostics, Unicode/control boundaries, numeric prefixes, multiple schemes and malformed fragments.
  • 20,120 deterministic inputs × 3 maskers × 2 host-mask states = 120,720 comparisons have zero byte differences. Both output streams hash to aa0bb0284216d3805be26cc5e282dae8eee5dac258c0c0514be53c9562b9b46f.
  • Three alternating before/after samples for a 40,000-character scheme-like run give median maskUrlsInText times 384.51 → 0.61 ms, and actual anonymous-provenance preview times 438.71 → 0.35 ms. Input construction and output hashing are outside the timed call. These are local synthetic measurements of this scan.
  • npm run typecheck, npm run build, npm run check:unused-exports, npm run check:test-import-graph, and git diff --check pass.
  • Independent read-only review checked candidate start positions, retained prefixes, malformed diagnostics and masking opt-out behavior.

The full-suite verdict remains the remote CI test lanes on the pushed head. No configuration, persistence format, wire/message shape, kernel behavior, dependency, or model-facing text changes.

Related work

#4402 establishes any-scheme URL masking and #6098 fixes credentials in loopback diagnostics; their semantics remain. #7359 (head 619b5299ccf32f9625b53617b9e0bfc3bb867402) concerns the separate Markdown delimiter parser and does not touch this matcher.

@ranxianglei ranxianglei changed the title fix: avoid repeated scheme scans in URL masking [PR] fix: avoid repeated scheme scans in URL masking Nov 20, 2026
@ranxianglei
ranxianglei merged commit bd737c9 into ranxianglei:master Nov 20, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] URL masking blocks processing of long unbroken text

2 participants