Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.
This repository was 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

@Velin92

Description

@Velin92

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions