pub enum HtmlAllowedUrlSchemes {
Listed(BTreeSet<UrlScheme>),
All,
}Expand description
The render option that decides which URL schemes the page may reference:
the schemes allowed in the URLs that the HTML backend writes into a link’s
href and an image’s src and srcset.
A URL with no scheme (a relative address, an address fragment) is always
allowed, whatever the value; the module documentation states the
whole policy. The default value is
Listed with
DEFAULT_ALLOWED_URL_SCHEMES.
The option is bound to the render request
(Bind::Render) and is set only by
Rust code: it is declared by the html feature beside its settings, not
among them, so no settings written as data can set it (who decides which
schemes are allowed). It is
an option type of its own rather than a field of
HtmlRenderOptions for that reason, and so
that a workflow’s value of it is never replaced when settings written as
data set a key of HtmlRenderOptions.
§Examples
A host that lets the page reference its own scheme app, beside the
default ones, and sets the value on its render request:
use flm_core::model::options::OptionValues;
use flm_core::stdlib::backends::html::{
AddressUse, HtmlAllowedUrlSchemes, UrlScheme, check_address,
};
let mut schemes = HtmlAllowedUrlSchemes::default_schemes();
schemes.insert(UrlScheme::new("app").expect("a scheme"));
let allowed = HtmlAllowedUrlSchemes::Listed(schemes);
assert!(check_address("app:open/42", AddressUse::Link, &allowed).is_ok());
assert!(check_address("javascript:alert(1)", AddressUse::Link, &allowed).is_err());
// Given to `PlanRequest::render_options`.
let render_options = OptionValues::new().with(allowed);Variants§
Listed(BTreeSet<UrlScheme>)
Only the URLs whose scheme is one of these, beside the URLs with no
scheme and, for an image, a data: URL carrying a picture. The list
replaces the default list: a host that adds a scheme to the default
ones starts from default_schemes.
All
Every URL, written as given whatever its scheme, javascript:
included: a link whose address is javascript:… then runs its program
in the reader’s browser when it is followed. Nothing is refused.
Implementations§
Source§impl HtmlAllowedUrlSchemes
impl HtmlAllowedUrlSchemes
Sourcepub fn default_schemes() -> BTreeSet<UrlScheme>
pub fn default_schemes() -> BTreeSet<UrlScheme>
Returns the default schemes, DEFAULT_ALLOWED_URL_SCHEMES, as the
set that the default value lists.
Trait Implementations§
Source§impl Clone for HtmlAllowedUrlSchemes
impl Clone for HtmlAllowedUrlSchemes
Source§impl Debug for HtmlAllowedUrlSchemes
impl Debug for HtmlAllowedUrlSchemes
Source§impl Default for HtmlAllowedUrlSchemes
impl Default for HtmlAllowedUrlSchemes
Source§fn default() -> HtmlAllowedUrlSchemes
fn default() -> HtmlAllowedUrlSchemes
impl Eq for HtmlAllowedUrlSchemes
Source§impl Hash for HtmlAllowedUrlSchemes
impl Hash for HtmlAllowedUrlSchemes
Source§impl PartialEq for HtmlAllowedUrlSchemes
impl PartialEq for HtmlAllowedUrlSchemes
impl StructuralPartialEq for HtmlAllowedUrlSchemes
Auto Trait Implementations§
impl Forget for HtmlAllowedUrlSchemes
impl Freeze for HtmlAllowedUrlSchemeswhere
*const LeafNode<UrlScheme, SetValZST> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(UrlScheme, SetValZST)>>: Freeze,
impl Move for HtmlAllowedUrlSchemes
impl RefUnwindSafe for HtmlAllowedUrlSchemes
impl Send for HtmlAllowedUrlSchemes
impl Sync for HtmlAllowedUrlSchemes
impl Unpin for HtmlAllowedUrlSchemes
impl UnsafeUnpin for HtmlAllowedUrlSchemeswhere
*const LeafNode<UrlScheme, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(UrlScheme, SetValZST)>>: UnsafeUnpin,
impl UnwindSafe for HtmlAllowedUrlSchemes
Blanket Implementations§
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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