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

Escaped at symbol in classes causes an issue with css purifier #3533

Closed
brianmercer opened this issue Aug 11, 2018 · 2 comments
Closed

Escaped at symbol in classes causes an issue with css purifier #3533

brianmercer opened this issue Aug 11, 2018 · 2 comments

Comments

@brianmercer
Copy link

brianmercer commented Aug 11, 2018

UIkit version

3.0.0-rc.11

What is Expected?

A css purifier will match the html class with the class in the stylesheet and leave the class in the stylesheet.

What is actually happening?

The css purifier removes the class from the stylesheet because the backslash prevents it from matching the html class.

I'm talking about the at symbol in classes like ".uk-child-width-auto@s".

My particular issue is that since they appear as ".uk-child-width-auto\@s" in the stylesheet, and therefore are not an exact match with the class in the html, my purifier (purge-css) removes them.

How about a nice underscore instead so they don't have to be escaped?

@szabeszg
Copy link

Many syntax highlighters also have trouble dealing with @. For example in Netbeans.
I wish it was configurable. Underscore is a nice alternative.

@brianmercer brianmercer changed the title Escaped ampersands in classes causes an issue with css purifier Escaped at symbol in classes causes an issue with css purifier Aug 11, 2018
@brianmercer
Copy link
Author

Resolved the issue by adding a custom extractor to purgecss that includes the at symbol in the regex.

            extractors: [
              {
                extractor: class {
                  static extract(content) {
                    return content.match(/[@A-Za-z0-9_-]+/g) || []
                  }
                },
                // Specify all necessary file types. There is no fallback to default.
                extensions: ["njk", "html", "whitelist"]
              }
            ]

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

2 participants