ldappostaladdr

Crates.ioldappostaladdr
lib.rsldappostaladdr
version1.0.1
created_at2025-08-18 10:15:32.522046+00
updated_at2025-08-18 10:24:24.893637+00
descriptionLDAP postal address parsing (zero-copy) and escape / unescape utilities
homepage
repositoryhttps://github.com/JonathanWilbur/asn1.rs/tree/master/ldappostaladdr
max_upload_size
id1800227
size18,608
Jonathan Wilbur (JonathanWilbur)

documentation

README

LDAP Postal Address Parser

This Rust crate parses Lightweight Directory Access Protocol (LDAP) postal addresses according to the syntax in IETF RFC 4517. It has no dependencies. This crate can function without a standard library (no_std), but alloc is required if you want to actually replace escape sequences or create new postal address strings. Without alloc, this crate merely detects escape sequences used in postal address lines, but does nothing about them.

This crate has been fuzz-tested. It checks for an odd number of trailing slashes in attribute values to prevent injection attacks.

Usage

You can parse and unescape LDAP postal addresses like so:

use ldappostaladdr::{parse_postal_address, unescape_postal_address_line};
let input = "\\241,000,000 Sweepstakes$PO Box 1000000$Anytown, CA 12345$USA";
let mut postal_address = parse_postal_address(input);
for (line, backslash_escaped, dollar_escaped) in postal_address {
  // This line returns Cow::Borrowed() if the line doesn't contain escape sequences.
  let unescaped_line = unescape_postal_address_line(line, backslash_escaped, dollar_escaped);
  info!(unescaped_line.as_ref());
}

AI Usage Statement

None of the code in this crate was produced by an AI or LLM of any kind.

Commit count: 447

cargo fmt