Expand description
Rust port of the Alap expression parser.
This is the server-side subset of alap/core (TypeScript). It covers
expression parsing, config merging, regex validation, and URL sanitization.
§Grammar
query = segment (',' segment)*
segment = term (op term)* refiner*
op = '+' | '|' | '-'
term = '(' segment ')' | atom
atom = ITEM_ID | CLASS | DOM_REF | REGEX | PROTOCOL
refiner = '*' name (':' arg)* '*'Re-exports§
pub use types::Config;pub use types::Link;pub use types::LinkWithId;pub use types::Macro;pub use types::Protocol;pub use types::ProtocolHandler;pub use types::RegexValidation;pub use types::Tier;
Modules§
- link_
provenance - Provenance tier stamping — Rust port of src/core/linkProvenance.ts.
- sanitize_
by_ tier - Tier-aware sanitizers — Rust port of src/core/sanitizeByTier.ts.
- types
- Configuration types for the Alap expression parser.
Structs§
- Expression
Parser - Resolves Alap expressions against a
Config. - Validate
Options - Options passed to
validate_config_with_options.
Constants§
- DEFAULT_
SCHEMES - Default allowlist used by
sanitize_url_with_schemeswhen the caller passesNone. http and https only. - STRICT_
SCHEMES - Allowlist used by
sanitize_url_strict: http / https / mailto.
Functions§
- cherry_
pick - Resolves an expression and returns a map of id → sanitized link.
- is_
private_ host - Check if a URL targets a private or reserved network address.
- merge_
configs - Shallow-merges multiple configs. Later configs win on collision.
- resolve
- Resolves an expression and returns matching links with sanitized URLs.
- sanitize_
link_ urls - Single source of truth for URL-scheme sanitization on a link.
- sanitize_
url - Returns the URL unchanged if safe, or
"about:blank"if it uses a dangerous scheme (javascript:,data:,vbscript:,blob:). - sanitize_
url_ strict - Strict URL sanitizer — http / https / mailto only (plus relative URLs and empty string). Use for links whose origin has not been verified as author-tier: protocol handler results, storage-loaded configs, etc.
- sanitize_
url_ with_ schemes - Sanitize
urlagainst a configurable scheme allowlist. - validate_
config - Validate and sanitize a
Configfrom an untrusted JSONValue, stamping each link withTier::Author. - validate_
config_ with_ options - Validate and sanitize a
Configfrom an untrusted JSONValue, stamping each link withopts.provenance. - validate_
regex - Checks whether a regex pattern compiles successfully.