Skip to content

Commit

Permalink
Escape non-US-ASCII characters in SassException.toCssString() (sass…
Browse files Browse the repository at this point in the history
…#2143)

Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
  • Loading branch information
2 people authored and Ludwig Meysel committed Feb 20, 2024
1 parent be20a48 commit 2970481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* Produce better output for numbers with complex units in `meta.inspect()` and
debugging messages.

* When generating CSS error messages to display in-browser, escape all code
points that aren't in the US-ASCII region. Previously only code points U+0100
LATIN CAPITAL LETTER A WITH MACRON were escaped.

### JS API

* Fix a bug where certain exceptions could produce `SourceSpan`s that didn't
Expand Down
4 changes: 2 additions & 2 deletions lib/src/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ class SassException extends SourceSpanException {
.replaceAll("\r\n", "\n");
term_glyph.ascii = wasAscii;

// For the string comment, render all non-ASCII characters as escape
// For the string comment, render all non-US-ASCII characters as escape
// sequences so that they'll show up even if the HTTP headers are set
// incorrectly.
var stringMessage = StringBuffer();
for (var rune in SassString(toString(color: false)).toString().runes) {
if (rune > 0xFF) {
if (rune > 0x7F) {
stringMessage
..writeCharCode($backslash)
..write(rune.toRadixString(16))
Expand Down

0 comments on commit 2970481

Please sign in to comment.