Skip to content

fix(#173): reject non-ASCII NFT IDs before byte slicing#322

Open
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-173
Open

fix(#173): reject non-ASCII NFT IDs before byte slicing#322
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-173

Conversation

@LeJamon

@LeJamon LeJamon commented May 30, 2026

Copy link
Copy Markdown

Closes #173.

parse_nftoken_id length-checks by byte count and then slices nft_id at fixed byte offsets ([0..4], [48..56], ...). A 64-byte string containing multibyte UTF-8 could land a slice boundary mid-character and panic.

Adds an is_ascii() guard before slicing, returning the new XRPLNFTIdException::InvalidNFTIdEncoding for non-ASCII input.

Testing

  • cargo test --lib — added test_parse_nftoken_id_non_ascii_returns_err_without_panic (a 64-byte input that previously panicked)
  • cargo fmt --check; no_std feature set green

parse_nftoken_id length-checks by byte count and then slices nft_id at
fixed byte offsets. A 64-byte string containing multibyte UTF-8 could land
a slice boundary mid-character and panic. Guard with an is_ascii() check
that returns the new InvalidNFTIdEncoding error.
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.

parse_nftoken_id slices by byte index; panics on non-ASCII 64-byte input

1 participant