Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines in attributes are lost #115

Closed
idubrov opened this issue Feb 5, 2018 · 3 comments
Closed

Newlines in attributes are lost #115

idubrov opened this issue Feb 5, 2018 · 3 comments
Labels

Comments

@idubrov
Copy link

idubrov commented Feb 5, 2018

Newlines in attributes are not encoded into XML escape sequence and are lost or re-parsing.

(https://stackoverflow.com/questions/2004386/how-to-save-newlines-in-xml-attribute)

@tafia tafia added the bug label Mar 1, 2018
@tafia
Copy link
Owner

tafia commented Mar 1, 2018

This is indeed looks like a bug.

@TakaakiFuruse
Copy link
Contributor

@idubrov
Is this what you mean?
I've wrote a test code on current master (15ee018) and made sure that it passed.
Am I doing right?

#[test]
fn test_newlines_in_attribute_should_not_be_lost() {
    let mut r = Reader::from_str("<tag1 attr1='line 1\nline 2'></tag1>");
    r.trim_text(true);
    let mut buf = Vec::new();
    match r.read_event(&mut buf) {
        Ok(Event::Start(ref e)) => match e.name() {
            b"tag1" => {
                let v = e.attributes().map(|a| a.unwrap().value).collect::<Vec<_>>();
                assert_eq!(v[0].clone().into_owned(), b"line 1\nline 2");
            }
            _ => (),
        },
        _ => (),
    }
}

@Mingun
Copy link
Collaborator

Mingun commented Dec 6, 2022

Fixed long time ago.

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

No branches or pull requests

4 participants