Skip to content

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

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

Closed
snshn opened this issue May 28, 2021 · 1 comment
Closed

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

snshn opened this issue May 28, 2021 · 1 comment

Comments

@snshn
Copy link

snshn commented May 28, 2021

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.

@snshn
Copy link
Author

snshn commented May 28, 2021

It looks like the optional space after the identifier can be trimmed without it breaking the desired behavior, while it makes the IE hack work. I'm gonna go ahead close this issue.

@snshn snshn closed this as completed May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant