Releases: cloudflare/lol-html
Releases · cloudflare/lol-html
v3.0.0
- Added
MemorySettings::with_graceful_bail_out_on_memory_limit_exceeded(): when set, the
rewriter flushes every input byte it has received but not yet emitted to the sink (as-is)
before returningMemoryLimitExceededError, so callers can continue the response by
writing subsequent bytes directly to their downstream sink instead of breaking it. - Added
Settings::with_graceful_bail_out_on_content_handler_error(): symmetric to the
memory setting above, but forRewritingError::ContentHandlerError. When set, the
rewriter flushes remaining input bytes before propagating a handler error, preserving
the response. Currently exposed via the Rust API only; the C API still uses the original
behavior. - Added
Settings::append_bail_out_handler()and the matchingbail_out!macro,
BailOutrewritable unit, andBailOutHandler/BailOutHandlerSendtype aliases.
Bail-out handlers fire immediately before the raw flush of remaining unparsed input on a
graceful bail-out (memory or content-handler error). Handlers receive the
RewritingErrorand aBailOutthrough which they can append final bytes to the sink
viaBailOut::append(content, content_type). Intended for handlers that buffer state
across the document (e.g. text-buffering handlers that defer emission) and need to
flush that state on bail-out. - Marked
RewritingError#[non_exhaustive]so future error variants can be added without
a major version bump. External callers can stillmatchon it, but must include a
catch-all_ =>arm. - Reworked
Settings,MemorySettingsandRewriteStrSettingsto use a consuming-builder
API. Fields are now private; construction is via::new()plus chainedwith_*setters
andappend_*methods for the content-handler vectors. This makes future field additions
non-breaking. Migration:// before Settings { element_content_handlers: vec![element!("div", |el| { /* ... */ Ok(()) })], strict: false, ..Settings::new() } // after Settings::new() .with_strict(false) .append_element_content_handler(element!("div", |el| { /* ... */ Ok(()) }))
- Renamed the internal-use feature
integration_testto_integration_test. The leading
underscore signals tocargo-semver-checksand similar tools that the feature is not
part of the public API. Comment::set_textnow also rejects--!>, a leading>, and a leading->, which
WHATWG-conformant browsers treat as comment terminators. Previously only-->was
rejected, so a caller passing attacker-influenced data could let an attacker break out
of the comment and inject HTML (security fix).