Skip to content

Commit

Permalink
fix: escape unicode characters in css with a double blackslash (#453)
Browse files Browse the repository at this point in the history
Closes #425
  • Loading branch information
appienvanveen authored and dherges committed Jan 11, 2018
1 parent 8954167 commit 9891128
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ yarn-error.log*
/.vs
/.idea

# IDE files
*.iml

# Runtime data
pids
*.pid
Expand Down
1 change: 1 addition & 0 deletions integration/samples/material/baz/baz.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

.baz {
color: $variable-defined-by-file-not-processed-by-loader;
content: "\2014 \00A0";
}
3 changes: 3 additions & 0 deletions integration/samples/material/specs/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ describe(`@sample/material`, () => {
it(`should have style with: "color: red"`, () => {
expect(METADATA['metadata'].BazComponent.decorators[0].arguments[0].styles[0]).to.have.string('color: "red"');
});
it(`should have style with: "content: \\2014 \\00A0"`, () => {
expect(METADATA['metadata'].BazComponent.decorators[0].arguments[0].styles[0]).to.have.string('content: "\\2014 \\00A0"');
});
});

});
Expand Down
3 changes: 3 additions & 0 deletions src/lib/steps/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const processStylesheet =
to: stylesheetFilePath.replace(path.extname(stylesheetFilePath), '.css')
});

// Escape existing backslashes for the final output into a string literal, which would otherwise escape the character after it
result.css = result.css.replace(/\\/g, '\\\\');

// Log warnings from postcss
result.warnings().forEach((msg) => {
log.warn(msg.toString());
Expand Down

0 comments on commit 9891128

Please sign in to comment.