diff --git a/src/interface.rs b/src/interface.rs index 317d7ce2..617a259b 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -176,10 +176,6 @@ pub fn set_mathml(mathml_str: impl AsRef) -> Result { static MATHJAX_V2: LazyLock = LazyLock::new(|| Regex::new(r#"class *= *['"]MJX-.*?['"]"#).unwrap()); static MATHJAX_V3: LazyLock = LazyLock::new(|| Regex::new(r#"class *= *['"]data-mjx-.*?['"]"#).unwrap()); - // Strip out processing instructions and comments -- these are not MathML and can cause DOS problems in the parser - static PROCESSING_INSTRUCTION: LazyLock = LazyLock::new(|| Regex::new(r#"<\?[\s\S]{1,2048}\?>"#).unwrap()); - static XML_COMMENT: LazyLock = LazyLock::new(|| Regex::new(r#"(?s)"#).unwrap()); - // These have some length limits to avoid DOS attacks via long strings static NAMESPACE_DECL: LazyLock = LazyLock::new(|| Regex::new(r#"xmlns:[[:alpha:]]{1,32}"#).unwrap()); static PREFIX: LazyLock = LazyLock::new(|| Regex::new(r#"() -> Result { let mut error_message = "".to_string(); // can't return a result inside the replace_all, so we do this hack of setting the message and then returning the error - let mathml_str = XML_COMMENT.replace_all(mathml_str, ""); - let mathml_str = PROCESSING_INSTRUCTION.replace_all(&mathml_str, ""); // FIX: need to deal with character data and convert to something the parser knows - let mathml_str = HTML_ENTITIES.replace_all(&mathml_str, |cap: &Captures| match HTML_ENTITIES_MAPPING.get(&cap[1]) { + let mathml_str = HTML_ENTITIES.replace_all(mathml_str, |cap: &Captures| match HTML_ENTITIES_MAPPING.get(&cap[1]) { None => { error_message = format!("No entity named '{}'", &cap[0]); cap[0].to_string()