Skip to content

serialize_identifier() appears to be appending whitespace after \9 #285

Closed
@snshn

Description

@snshn

I encountered something interesting, thanks to a little-known hack that IE[7-9] uses.

Here's my snippet:

pub fn format_ident(ident: &str) -> String {
    let mut res: String = String::new();
    let _ = serialize_identifier(ident, &mut res);
    res = res.trim_end().to_string(); // <-- Had to add this line
    res
}

Appears to be that passing value \9 via Token::Ident to that function results in serialize_identifier() writing \9 rather than \9, hence it was breaking the original CSS hack. The test query I used is this one: div#p>svg>foreignObject>section:not(\9) and pushing that through the serialize_identifier without trim_end() was resulting in div#p>svg>foreignObject>section:not(\9 ) and hence was breaking that IE hack. I couldn't find where my code was adding extra space at the end for tabs, hence went with right-trimming it for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions