Skip to content

css-loader incorrectly process escaped characters within the content CSS property #87

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
andreypopp opened this issue Jun 25, 2015 · 7 comments

Comments

@andreypopp
Copy link
Contributor

Repro: https://gist.github.com/andreypopp/e3a8f338d21b1b4eebd2

Bootstrap has the following glyphicon class definition, bootstrap/dist/css/bootstrap.css:

.glyphicon-plus:before {
  content: "\2b";
}

which is processed by webpack into bundle.js:

.glyphicon-plus:before{content:"2b"}

So instead of the icon I see "2b" in the browser.

Note that other icons with escape codes like:

.glyphicon-pencil:before {
  content: "\270f";
}
.glyphicon-glass:before {
  content: "\e001";
}

are processed just fine.

@andreypopp
Copy link
Contributor Author

Also note that I'm not sure if shorthand escape codes are valid in CSS so that might be a bug in Twitter Bootstrap instead.

@mathieumg
Copy link

I imagine this is from master? If this is from 0.15.1, it might already be fixed. See #79. There has been no new tag since.

@andreypopp
Copy link
Contributor Author

@markdalgleish I get version of css-selector-tokenizer@0.5.2 with fixes for #79 but the reported issue still manifests itself. Also reproducible with css-loader from master.

@JackVCurtis
Copy link

I got this to work by changing css-selector-tokenizer/parseValues.js, line 26.
Was: return content.replace(/\\([a-fA-F0-9]{4}|.)/g, function(escaped) {
Fixed: return content.replace(/\\([a-fA-F0-9]{2,4}|.)/g, function(escaped) {

Although rather than edit the library, it's probably easier to override glyphicon-asterisk and glyphicon-plus. These work fine:

.glyphicon-asterisk               { &:before { content: "\002a"; } }
.glyphicon-plus                   { &:before { content: "\002b"; } }

@andreypopp
Copy link
Contributor Author

I'd rather make sure css-loader works with bootstrap (and probably with other CSS as two-char-escape codes seems like a thing) out of the box. Let's create a pull request!

@JackVCurtis
Copy link

Oh, definitely fix the loader. I was just going to use the second fix until the pull request is closed. I spent way too much time today thinking I wasn't loading fonts correctly...

@chandlervdw
Copy link

@sokra I am still having this issue, even though I've got css-selector-tokenizer v0.5.4...

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

4 participants