Skip to content

fix(rust): handle single-character ALPN according to spec (#325) - #327

Merged
vlvkobal merged 2 commits into
FoxIO-LLC:mainfrom
Aditya-9-6:fix/rust-single-char-alpn-325
Oct 6, 2026
Merged

vlvkobal merged 2 commits into
FoxIO-LLC:mainfrom
Aditya-9-6:fix/rust-single-char-alpn-325

Conversation

@Aditya-9-6

Copy link
Copy Markdown
Contributor

Summary

According to the JA4 specification, a single-character ALPN value should use that character for both the first and last positions (e.g., "x" -> "xx" instead of "x0").

This aligns the Rust implementation with the Python fix implemented in #322.

Changes

  • In rust/ja4/src/tls.rs (first_last), when chars.next_back() returns None for single-character strings, fall back to first using .or(first).
  • Updated test_first_last() and test_first_last_non_ascii() to verify single-character ASCII and non-ASCII ALPN behavior.
  • Added test_single_char_alpn_fingerprints() to verify that both client (PartsOfClientFingerprint) and server (ServerStats) JA4 outputs format single-character ALPN as "xx".
  • Added an entry in rust/CHANGELOG.md under [Unreleased].

Verification

Local test verification passed with zero failures or warnings:

  • cargo fmt --check --all (Clean)
  • cargo clippy --all-features --workspace -- -D warnings (Clean, 0 warnings)
  • cargo test --locked --all-features --all-targets --workspace (All 25 tests passed)
  • cargo test --locked --all-features --doc --workspace (Passed)
  • cargo doc --no-deps --all-features --document-private-items --workspace (Passed)

Closes #325

Aditya-9-6 and others added 2 commits October 2, 2026 22:29
…LLC#325)

For a one-character ALPN, the JA4 spec dictates that a single character
should supply both first and last positions (e.g. 'x' -> 'xx'), mirroring
the Python fix in FoxIO-LLC#322.

Closes FoxIO-LLC#325
@vlvkobal

vlvkobal commented Oct 6, 2026

Copy link
Copy Markdown
Member

I removed the changelog entry since rust/CHANGELOG.md hasn’t been maintained for quite a while. I think we should probably remove the stale changelog rather than start updating it selectively again here.

@vlvkobal
vlvkobal merged commit c6469a7 into FoxIO-LLC:main Oct 6, 2026
9 checks passed
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.

Handle single-character ALPN according to the spec

2 participants