Skip to content

Addressing issues: [29,31,68,76,100,30 and 31] - #106

Open
jer-gremlin wants to merge 18 commits into
whisperfish:mainfrom
jer-gremlin:main
Open

jer-gremlin wants to merge 18 commits into
whisperfish:mainfrom
jer-gremlin:main

Conversation

@jer-gremlin

@jer-gremlin jer-gremlin commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Hiya,

I wanted to use this in a POC, but the client doesn't allow things with open issues/sev vulns so:

  ┌───────┬────────────────────┬─────────────────────┬──────────────────────────┐
  │ Issue │       Input        │       Current       │         Expected         │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #100  │ +3367a829916       │ +33672829916 (a→2)  │ +3367829916 (a stripped) │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #76   │ +78005553535 RU    │ +7005553535 invalid │ +78005553535             │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #68   │ 3912312312 None    │ InvalidCountryCode  │ parse as IT              │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #31   │ +97233142764978    │ valid=true          │ invalid (too long)       │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #30   │ +33142764978 US    │ +3342764978         │ +33142764978             │
  ├───────┼────────────────────┼─────────────────────┼──────────────────────────┤
  │ #29   │ 0032474123456 None │ InvalidCountryCode  │ +32474123456             │
  └───────┴────────────────────┴─────────────────────┴──────────────────────────┘

some opinionated fixes for the above, take them if you want -- or not.

if you'd rather cherry from the fixes individually

Addresses #100 #76 #68 #31 #30 #29

@jer-gremlin
jer-gremlin marked this pull request as ready for review June 11, 2026 22:58
@rubdos

rubdos commented Jun 27, 2026

Copy link
Copy Markdown
Member

Hi! Thanks for your contributions. I've cherry picked the CVE tests, the concurrency test, country-code metadata patch, leading zero patch, and the vanity number patch. Your other changes require a bit more energy to review. Would you be able to rebase your PR on main?

I have also bumped MSRV to 1.85 and edition to 2024 to avoid the awkward if-let-change avoidance.

@codecov

codecov Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.67987% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.39%. Comparing base (fcc55a6) to head (7500884).

Files with missing lines Patch % Lines
src/parser/helper.rs 90.62% 3 Missing ⚠️
src/parser/rfc3986.rs 98.27% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   68.15%   71.39%   +3.24%     
==========================================
  Files          18       22       +4     
  Lines        2179     2444     +265     
==========================================
+ Hits         1485     1745     +260     
- Misses        694      699       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jer-gremlin

Copy link
Copy Markdown
Contributor Author

Hi! Thanks for your contributions. I've cherry picked the CVE tests, the concurrency test, country-code metadata patch, leading zero patch, and the vanity number patch. Your other changes require a bit more energy to review. Would you be able to rebase your PR on main?

I have also bumped MSRV to 1.85 and edition to 2024 to avoid the awkward if-let-change avoidance.

Sure thing.

Descriptor national-number regexes were matched with find(), accepting
a match that merely started at index 0. A shorter pattern (e.g. an
8-digit rule) therefore matched a prefix of a longer, invalid number,
so numbers like +97233142764978 were reported valid.

Anchor the patterns with \A(?:...)\z at build time and use full-string
is_match, matching libphonenumber's matches() semantics.

Closes whisperfish#31
Parsing 3912312312 with reference IT stripped the leading 39 (Italy's
calling code), yielding the invalid 12312312. The default-region branch
stripped the country code whenever the number began with it and was not
'possible', which for regions without explicit length data is always.

Adopt libphonenumber's rule: strip the default region's country code
only when the full number is not a valid national number but the
candidate (country code + national prefix removed) is, or the full
number is too long.

This relies on national-number patterns matching the whole string, so
it also anchors those patterns (same change as the whisperfish#31 fix); merge that
branch first to avoid a duplicate.

Closes whisperfish#68
National-prefix stripping removed a leading digit even when the result
was no longer a valid national number, so RU/KZ/BY numbers like
+78005553535 became +7005553535.

- The for-parsing branch checked the whole number for viability instead
  of the remainder after the prefix; check number[end..] instead.
- The plain national-prefix branch stripped unconditionally; add the
  same viability check.
- Remove the duplicate unconditional strip in parse_with.
- Fix capture-group off-by-one (captures_len includes group 0) and the
  latent panic on a transform rule without a capturing group.

Closes whisperfish#76
Add parser::rfc3986 with RFC 3986 §2.1 percent-decoding. The rfc3966
parser now accepts pct-encoded octets in the national number and
phone-context, decoding them to their literal characters (e.g. %2D to
-, %2B to +) before interpretation. Malformed escapes and octets that
are not valid UTF-8 are rejected as parse errors.
Add parser::rfc4715, exposing the isub and isub-encoding tel-URI
parameters (RFC 4715) through a dedicated subaddress() parser. The
sub-address is auxiliary routing data rather than part of the E.164
number, so it is surfaced separately rather than on PhoneNumber.
Add parser::rfc4904, exposing the tgrp and trunk-context tel-URI
parameters (RFC 4904) through a dedicated trunk_group() parser. Trunk
groups are routing metadata rather than part of the E.164 number, so
they are surfaced separately rather than on PhoneNumber.
Add parser::rfc3601, parsing the dial-sequence notation (phone-string)
of RFC 3601: DTMF digits and tones, one-second pauses (p), waits for
dial tone (w), and visual separators. A dial sequence carries tones and
timing that an E.164 number cannot, so it is parsed independently of
PhoneNumber and exposed as DialSequence.
Re-export the rfc3601, rfc3986, rfc4715 and rfc4904 parser modules so
the dial-sequence, percent-decoding, ISDN sub-address and trunk-group
APIs are reachable by downstream callers.
@jer-gremlin

Copy link
Copy Markdown
Contributor Author

Hi! Thanks for your contributions. I've cherry picked the CVE tests, the concurrency test, country-code metadata patch, leading zero patch, and the vanity number patch. Your other changes require a bit more energy to review. Would you be able to rebase your PR on main?

I have also bumped MSRV to 1.85 and edition to 2024 to avoid the awkward if-let-change avoidance.

Wanna remove the 1.76 version from the CI pipe then?

@jer-gremlin

Copy link
Copy Markdown
Contributor Author

@rubdos all good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants