pub struct MDLinkFormatter;
Expand description
Default link validator and formatter for markdown-it.
This validator can prohibit more than really needed to prevent XSS. It’s a tradeoff to keep code simple and to be secure by default.
If you need a different setup-override the validator method as you wish. Or replace it with a placeholder function and use external sanitizer.
Implementations§
Trait Implementations§
Source§impl Debug for MDLinkFormatter
impl Debug for MDLinkFormatter
Source§impl Default for MDLinkFormatter
impl Default for MDLinkFormatter
Source§fn default() -> MDLinkFormatter
fn default() -> MDLinkFormatter
Returns the “default value” for a type. Read more
Source§impl LinkFormatter for MDLinkFormatter
impl LinkFormatter for MDLinkFormatter
Source§fn validate_link(&self, url: &str) -> Option<()>
fn validate_link(&self, url: &str) -> Option<()>
Validate the link url, return
Some(())
if it is allowed
and None
if it is a security risk.Source§fn normalize_link(&self, url: &str) -> String
fn normalize_link(&self, url: &str) -> String
Encode link url to a machine-readable format,
which includes url-encoding, punycode, etc.
Source§fn normalize_link_text(&self, url: &str) -> String
fn normalize_link_text(&self, url: &str) -> String
Decode link url to a human-readable format.
Auto Trait Implementations§
impl Freeze for MDLinkFormatter
impl RefUnwindSafe for MDLinkFormatter
impl Send for MDLinkFormatter
impl Sync for MDLinkFormatter
impl Unpin for MDLinkFormatter
impl UnwindSafe for MDLinkFormatter
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.