Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Setting a an html/xml like content as markdown, returns empty text #910

Open
Velin92 opened this issue Dec 19, 2023 · 0 comments
Open

Setting a an html/xml like content as markdown, returns empty text #910

Velin92 opened this issue Dec 19, 2023 · 0 comments

Comments

@Velin92
Copy link
Member

Velin92 commented Dec 19, 2023

While investigating this issue: element-hq/element-x-ios#2265

We found out that when RTE is disabled which means that plain text mode is enabled and so markdown is parsed directly by our Rust markdown to html parser, any content that looks like html or xml is completely ignored and sicarded returning an empty message.
I wrote a test case for it:

fn set_content_from_markdown_that_contains_xml() {
    let mut model = cm("|");
    model
        .set_content_from_markdown(&utf16(
            r#"<message id="1" to="123456789098765@lid" type="text">
        <enc v="2" type="pkmsg" count="[1,5]" >...CIPHERTEXT[Alice]...</enc>
  </message>"#,
        ))
        .unwrap();
    assert_eq!(
        tx(&model),
        r#"<message id="1" to="123456789098765@lid" type="text">
    <enc v="2" type="pkmsg" count="[1,5]" >...CIPHERTEXT[Alice]...</enc>
</message>|"#
    );

The tests fails with the following error:

panicked at 'assertion failed: `(left == right)`
 left: `"|"`,
right: `"<message id=\"1\" to=\"123456789098765@lid\" type=\"text\">\n    <enc v=\"2\" type=\"pkmsg\" count=\"[1,5]\" >...CIPHERTEXT[Alice]...</enc>\n</message>|"`', crates/wysiwyg/src/tests/test_set_content.rs:251:5

The conversion fails here:
https://github.com/matrix-org/matrix-wysiwyg/blob/fcfef8a6f59880de90156f3daa46c60b6328311b/crates/wysiwyg/src/composer_model/base.rs#L125
In fact the markdown to html conversion works, is the set_html of the parsed html that is not converted properly into out dom supported html and fails, giving us an empty dom/html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant