Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

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

Closed

Description

@andreypopp

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.

Activity

  1. andreypopp commented on Jun 25, 2015

    @andreypopp
    ContributorAuthor

    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.

  2. mathieumg commented on Jun 25, 2015

    @mathieumg

    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.

  3. andreypopp commented on Jun 25, 2015

    @andreypopp
    ContributorAuthor

    @markdalgleish I get version of [email protected] with fixes for #79 but the reported issue still manifests itself. Also reproducible with css-loader from master.

  4. JackVCurtis commented on Jun 25, 2015

    @JackVCurtis

    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"; } }
    
  5. andreypopp commented on Jun 25, 2015

    @andreypopp
    ContributorAuthor

    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!

  6. JackVCurtis commented on Jun 25, 2015

    @JackVCurtis

    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...

  7. chandlervdw commented on Sep 3, 2015

    @chandlervdw

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions