Enum ScopeMode
pub enum ScopeMode {
Browser,
NearestMatch,
}html and http and std only.Expand description
How the rewriter decides where elements end in markup that leaves end tags out, misnests them, or adds stray ones.
The rewriter never rejects or stalls on such input; this only chooses whose view of the document it follows. It is fixed once input has been written.
Variants§
Browser
Parse the input as a full document with the WHATWG tree-construction
rules established browsers apply: implied ends (<li>, <p>, table
parts, <option>, ruby, headings, buttons) and end tags only reach
elements in scope, </x> never crosses a special element, tables,
templates and SVG/MathML integration points shield their contents,
</body> and </html> leave everything open (their end-anchored edits
still land before the tag), the self-closing flag is honoured only
where browsers honour it (void and foreign elements), and raw-text
bodies (<style>, <textarea>, …) and CDATA sections are recognised
exactly where browsers recognise them.
Elements browsers create without a tag (html, head, body,
tbody, tr, colgroup) take part in selector ancestry and sibling
positions, though only a tag can be matched: a late <html> or
<body>, or a <head> for the head browsers created on their own, is
matched as that element. Tags browsers drop (a <tr> outside a table,
a second <head>, …) match nothing, so markup meant to be inserted
into a table or another element is better rewritten with
NearestMatch.
A streaming rewriter cannot restructure what it already emitted. This is not a full browser DOM or a sanitizer. In particular:
- formatting elements (
a,b,i, …) are not split or implicitly closed by another formatting start tag. Their end tags close a matching frame only when no special element needs restructuring; reconstructed copies of formatting elements are not tracked, so aremovedoes not reach content browsers move into such a copy; - a
</form>that browsers apply to a form with still-open children keeps the form open until its parent closes; - content browsers move out in front of a table (foster parenting)
stays part of the table for
removeandset_inner_content: more is removed, never less (selectors still see its real parent); - a tag matched as an element that is already open (a late
<html>or<body>) applies its edits from where it appears: content streamed before it is not retracted, and its attributes reach selector ancestry of later elements only; - frameset documents, iframe
srcdocquirks and scripting-disabled<noscript>parsing are not modelled; - where established browsers disagree, the Chromium and WebKit
behaviour is followed:
<![CDATA[in an SVG/MathML integration point is a bogus comment, a<form>in a table inside a<template>is kept, an empty doctype system identifier counts as missing, andsearchanddialogdo not stop end-tag and list-item walks. Inside<select>the current (relaxed) select parsing of Chromium and Gecko is followed, not the legacy one some WebKit releases still use.
NearestMatch
Close the nearest open element with a matching name, ignoring scope
boundaries: the behaviour of simpler streaming rewriters, which also
treats every tag as an element where it appears (fragments included).
A hostile document can use it to end an element early, so prefer
Browser for markup you do not control.
Trait Implementations§
impl Copy for ScopeMode
impl Eq for ScopeMode
impl StructuralPartialEq for ScopeMode
Auto Trait Implementations§
impl Freeze for ScopeMode
impl RefUnwindSafe for ScopeMode
impl Send for ScopeMode
impl Sync for ScopeMode
impl Unpin for ScopeMode
impl UnsafeUnpin for ScopeMode
impl UnwindSafe for ScopeMode
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more