Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ pub fn set_mathml(mathml_str: impl AsRef<str>) -> Result<String> {

// Strip out processing instructions and comments -- these are not MathML and can cause DOS problems in the parser
static PROCESSING_INSTRUCTION: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"<\?[\s\S]{1,2048}\?>"#).unwrap());
static XML_COMMENT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"(?s)"#).unwrap());

// These have some length limits to avoid DOS attacks via long strings
static NAMESPACE_DECL: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"xmlns:[[:alpha:]]{1,32}"#).unwrap());
Expand All @@ -204,8 +203,7 @@ pub fn set_mathml(mathml_str: impl AsRef<str>) -> Result<String> {

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, "");
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]) {
None => {
Expand Down
Loading