Skip to content

CSS url with spaces not escaped in output #410

Closed
@romanzoller

Description

@romanzoller

Do you want to request a feature or report a bug?
bug

What is the current behavior?
For input:

.red-square {
  content:  url("red dot.png");
}

the output in combination with file loader name: '[name].[ext]' is:

.red-square {
  content: url(red dot.png);
}

(note that "" are missing)

If the current behavior is a bug, please provide the steps to reproduce.

See https://github.com/romanzoller/css-loader-url for complete example.

What is the expected behavior?

Output should be:

.red-square {
  content: url("red dot.png");
}

and/or space should be escaped in another way.

See CSS spec:

The format of a URI value is 'url(' followed by optional white space followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional white space followed by ')'. The two quote characters must be the same.

and

Some characters appearing in an unquoted URI, such as parentheses, white space characters, single quotes (') and double quotes ("), must be escaped with a backslash so that the resulting URI value is a URI token: '(', ')'.

Please mention other relevant information such as your webpack version, Node.js version and Operating System.

package.json:

{
  "scripts": {
    "build": "NODE_ENV=production webpack && cp src/index.html dist/index.html"
  },
  "devDependencies": {
    "css-loader": "^0.26.1",
    "file-loader": "^0.9.0",
    "style-loader": "^0.13.1",
    "webpack": "^1.14.0"
  }
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions