diff --git a/src/export/html.rs b/src/export/html.rs index 7e1ccef..5dff5f2 100644 --- a/src/export/html.rs +++ b/src/export/html.rs @@ -17,9 +17,9 @@ use crate::export::write_datetime; /// "<script>alert('Hello XSS')</script>" /// ); /// ``` -pub struct Escape>(pub S); +pub struct HtmlEscape>(pub S); -impl> fmt::Display for Escape { +impl> fmt::Display for HtmlEscape { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut pos = 0; @@ -81,7 +81,7 @@ pub trait HtmlHandler>: Default { ExampleBlock(block) => write!( w, "
{}
", - Escape(&block.contents) + HtmlEscape(&block.contents) )?, ExportBlock(block) => { if block.data.eq_ignore_ascii_case("HTML") { @@ -93,14 +93,14 @@ pub trait HtmlHandler>: Default { write!( w, "
{}
", - Escape(&block.contents) + HtmlEscape(&block.contents) )?; } else { write!( w, "
{}
", block.language, - Escape(&block.contents) + HtmlEscape(&block.contents) )?; } } @@ -109,16 +109,16 @@ pub trait HtmlHandler>: Default { w, "{}", inline_src.lang, - Escape(&inline_src.body) + HtmlEscape(&inline_src.body) )?, - Code { value } => write!(w, "{}", Escape(value))?, + Code { value } => write!(w, "{}", HtmlEscape(value))?, FnRef(_fn_ref) => (), InlineCall(_) => (), Link(link) => write!( w, "{}", - Escape(&link.path), - Escape(link.desc.as_ref().unwrap_or(&link.path)), + HtmlEscape(&link.path), + HtmlEscape(link.desc.as_ref().unwrap_or(&link.path)), )?, Macros(_macros) => (), RadioTarget => (), @@ -128,7 +128,7 @@ pub trait HtmlHandler>: Default { } } Target(_target) => (), - Text { value } => write!(w, "{}", Escape(value))?, + Text { value } => write!(w, "{}", HtmlEscape(value))?, Timestamp(timestamp) => { use crate::elements::Timestamp; @@ -152,16 +152,20 @@ pub trait HtmlHandler>: Default { write_datetime(&mut w, "[", start, "]–")?; write_datetime(&mut w, "[", end, "]")?; } - Timestamp::Diary { value } => write!(&mut w, "<%%({})>", Escape(value))?, + Timestamp::Diary { value } => { + write!(&mut w, "<%%({})>", HtmlEscape(value))? + } } write!(&mut w, "")?; } - Verbatim { value } => write!(&mut w, "{}", Escape(value))?, + Verbatim { value } => write!(&mut w, "{}", HtmlEscape(value))?, FnDef(_fn_def) => (), Clock(_clock) => (), Comment { .. } => (), - FixedWidth { value } => write!(w, "
{}
", Escape(value))?, + FixedWidth { value } => { + write!(w, "
{}
", HtmlEscape(value))? + } Keyword(_keyword) => (), Drawer(_drawer) => (), Rule => write!(w, "
")?, diff --git a/src/export/mod.rs b/src/export/mod.rs index 09641eb..4eddfba 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -3,9 +3,9 @@ mod html; mod org; -pub use html::{DefaultHtmlHandler, Escape as HtmlEscape, HtmlHandler}; #[cfg(feature = "syntect")] pub use html::SyntectHtmlHandler; +pub use html::{DefaultHtmlHandler, HtmlEscape, HtmlHandler}; pub use org::{DefaultOrgHandler, OrgHandler}; use std::io::{Error, Write};