taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit 2fcc1cc40646cf14e20226dcfc1315da02988297
parent 463d24d76e4a0ed5369e30b3ebd9de269f83b69c
Author: Antoine A <>
Date:   Thu, 24 Sep 2026 12:33:26 +0200

common: optimize/fix subject parsing

Diffstat:
Mcommon/taler-api/src/subject.rs | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/common/taler-api/src/subject.rs b/common/taler-api/src/subject.rs @@ -197,8 +197,8 @@ pub fn fmt_in_subject(ty: IncomingType, key: &EddsaPublicKey) -> impl Display { * parts, resolving ambiguities where possible. **/ pub fn parse_incoming_unstructured(subject: &str) -> Result<IncomingSubject, IncomingSubjectErr> { - // We expect subject to be less than 65KB - assert!(subject.len() <= u16::MAX as usize); + // We expect subject to be less than 4GB + assert!(subject.len() <= u32::MAX as usize); const KEY_SIZE: usize = 52; const PREFIXED_SIZE: usize = KEY_SIZE + 3; @@ -242,11 +242,13 @@ pub fn parse_incoming_unstructured(subject: &str) -> Result<IncomingSubject, Inc let (parts, concatenated) = { let mut parts = Vec::with_capacity(4); let mut concatenated = String::with_capacity(subject.len().min(PREFIXED_SIZE + 10)); - parts.push(0u16); + parts.push(0u32); for part in subject.as_bytes().split(|b| !b.is_ascii_alphanumeric()) { - // SAFETY: part are all valid ASCII alphanumeric - concatenated.push_str(unsafe { std::str::from_utf8_unchecked(part) }); - parts.push(concatenated.len() as u16); + if !part.is_empty() { + // SAFETY: part are all valid ASCII alphanumeric + concatenated.push_str(unsafe { std::str::from_utf8_unchecked(part) }); + parts.push(concatenated.len() as u32); + } } (parts, concatenated) };