feat(parsers): format-specific right-boundary guards for IP/MAC/UUID/JWT/SSN - #10
Draft
ClaudiuCeia with Copilot wants to merge 4 commits into
Draft
feat(parsers): format-specific right-boundary guards for IP/MAC/UUID/JWT/SSN#10ClaudiuCeia with Copilot wants to merge 4 commits into
ClaudiuCeia with Copilot wants to merge 4 commits into
Conversation
…d IPv6 - Add `boundary()` (zero-width word boundary) and `strictBoundary(p, extraPattern)` (zero-width + format-specific non-word char rejection) to src/common.ts - Language.ts: use `boundary()` instead of `dot()` so structural chars like `+` adjacent to a phone number are not consumed (fixes English+14155552671 case) - UUID.ts: use `strictBoundary(s.Full, /[-]/)` — rejects trailing hyphen to prevent prefix match in `550e8400-...-0000-dead` - JWT.ts: use `strictBoundary(s.Full, /[.]/)` — rejects trailing period to prevent prefix match in `<jwt>.extra` - SSN.ts: use `strictBoundary(s.Full, /[-]/)` — rejects trailing hyphen to prevent prefix match in `123-45-6789-00` - MACAddress.ts: use per-format `strictBoundary()` — colon MAC rejects `:`, hyphen MAC rejects `-`, Cisco dot MAC rejects `.` - IPAddress.ts: custom IPv4/IPv6-compressed boundary helpers with 2-char dot+digit lookahead (allows sentence periods, rejects 5th octet / extra groups); add IPv4-mapped IPv6 parser (Full6v4) to correctly handle `::ffff:192.0.2.128` - Tests: prefix rejection cases for IPv6/MAC/UUID/SSN/JWT, IPv4-mapped IPv6 full match, Language+Phone adjacent entities, sync/async scanner parity tests Closes #5
…ndle zero-group IPv4-mapped IPv6
Copilot
AI
changed the title
[WIP] Fix format-specific boundaries for IP/MAC/UUID/JWT/SSN
feat(parsers): format-specific right-boundary guards for IP/MAC/UUID/JWT/SSN
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dot()consumes any non-word char as a trailing delimiter, causing parsers to accept structurally invalid prefixes (e.g.1:2:3:4:5:6:7:8:9matches as the 8-group IPv6 prefix;123-45-6789-00matches as SSN).New primitives (
src/common.ts)boundary(p)— zero-width word boundary; succeeds if next char is\Wor EOF, does not consume the delimiterstrictBoundary(p, extraPattern)— same, but additionally rejects specific non-word structural charsThese sit alongside
dot(), which is left unchanged to avoid breaking compound parsers (Range, Time.Relative) that rely on child parsers consuming trailing whitespace.Per-parser migrations
Languageboundary()English+14155552671→ two entities)UUIDstrictBoundary-JWTstrictBoundary.SSNstrictBoundary-MACAddressstrictBoundaryper format:/-/.(own separator only)IPv4ipv4Boundary()\wand.followed by digit (5th octet), but not sentence periodIPv6 fullstrictBoundary:(9th group)IPv6 compressedipv6CompBoundary():and.followed by digitIPv4-mapped IPv6 correctness fix
::ffff:192.0.2.128previously failed becausehexChaingreedily consumedffff:192as two hex groups. Added a newhexGroupsPrefixregex (/(?:[0-9a-fA-F]{1,4}:)+/) that requires a trailing:per group, paired with a newIPv6v4Mappedparser tried beforeIPv6Compressed.Tests added
All prefix-rejection cases from the issue, IPv4-mapped IPv6 variants,
English+14155552671producing both a language and phone entity, and sync/async scanner parity for all affected formats.