Commit Graph

8 Commits

Author SHA1 Message Date
kay ozaki f2d98eaf62 psl: normalize domains before psl::domain_str / suffix_str lookups
The `psl` crate's domain_str / suffix_str do byte-exact lookups against
the public-suffix list, so uppercase or trailing-dot inputs (e.g.
"Example.COM" or "example.com." from a DNS Name) silently return None.
Several call sites were passing through user- or DNS-supplied domains
unmodified.

Add a small psl-utils crate that wraps the psl crate:

* normalize_domain(&str) -> Cow<str>: strips a single trailing dot and
  lowercases ASCII; borrows when the input is already normalized so
  the hot path (alignment loop) doesn't allocate.
* domain_str / suffix_str: thin re-exports for callers that have
  already normalized.

psl-utils becomes the only workspace crate that directly depends on
the psl crate; kumo-dmarc and mod-string switch to depending on
psl-utils instead.

Updated call sites:

* kumo-dmarc record.rs: is_relaxed_aligned / is_strict_aligned now
  normalize both inputs first. Replaces the prior eq_ignore_ascii_case
  comparisons.
* kumo-dmarc lib.rs: the organizational-domain fallback in
  DmarcContext::check now normalizes from_domain before calling
  domain_str and compares against the normalized form. Previously a
  mixed-case From: header would skip the _dmarc.<org> lookup entirely.
* mod-string lib.rs: the Lua-exposed string.psl_domain and
  string.psl_suffix bindings normalize their input. Behavior change:
  inputs that previously returned nil due to case or trailing dot now
  resolve.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Closes: https://github.com/KumoCorp/kumomta/pull/513
2026-05-06 13:34:15 +00:00
kay ozaki 77a8e951c5 mod-string: add ends_with, starts_with
closes: https://github.com/KumoCorp/kumomta/pull/498
2026-03-31 15:23:49 +01:00
Wez Furlong 16f019794e kumo-wrap: enable operating on bytes 2026-03-28 07:20:26 +00:00
Wez Furlong 9ea28f9c2f template: add optional dialect argument to kumo.string.eval_template
refs: https://github.com/KumoCorp/kumomta/issues/446
2025-11-09 07:53:19 +00:00
Wez Furlong 6adb43221f Expose text wrapping function as kumo.string.wrap
Extracts the wrap function to its own little crate and expose that to
lua.
2025-10-29 12:06:06 +00:00
Wez Furlong 7cf6b93783 memory: allow setting soft and low memory limit/thresholds
If you have a lot of RAM, using only default percentages could
potentially leave some RAM unused.  These lua functions
allow more precise control over the limits.
2025-02-20 12:06:12 -07:00
Wez Furlong 1ce8239dd9 add kumo.string.eval_template function 2025-02-20 08:52:04 -07:00
Wez Furlong 10bb7f2717 Add some string and regex functions
closes: https://github.com/KumoCorp/kumomta/issues/220
2024-06-21 17:20:04 -07:00