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

Bad regex in DefaultExtractor matches special characters #37

Closed
SebastianS90 opened this issue Dec 31, 2017 · 2 comments
Closed

Bad regex in DefaultExtractor matches special characters #37

SebastianS90 opened this issue Dec 31, 2017 · 2 comments

Comments

@SebastianS90
Copy link

The default extractor regex in version v0.16.0 is /[A-z0-9-]+/g

The range A-z includes all ascii characters between A (65) and z (122), in particular also the range from 91 to 96, which is [ \ ] ^ _ `

This was probably not intended. I would suggest the following regex: /[A-Za-z0-9-]+/g

'foo[bar] foo^bar foo`bar`baz'.match(/[A-z0-9-]+/g)
~> [ 'foo[bar]', 'foo^bar', 'foo`bar`baz' ]

'foo[bar] foo^bar foo`bar`baz'.match(/[A-Za-z0-9-]+/g)
~> [ 'foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'baz' ]

See also: FullHuman/purgecss-webpack-plugin#7

@Ffloriel
Copy link
Member

Ffloriel commented Jan 2, 2018

Thank you for reporting the issue. It's actually a known issue thanks to FullHuman/purgecss-webpack-plugin#7.

As suggested by @jsnanigans, the default extractor will be modified to /[A-Za-z0-9_-]+/g.
_ is commonly used for css selectors, especially with the bem methodology.

@Ffloriel
Copy link
Member

Ffloriel commented Jan 5, 2018

The default extractor has been modified in the latest version: 0.18.0.

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