Skip to content

Commit

Permalink
Escape the source map URL before using it in a CSS comment
Browse files Browse the repository at this point in the history
The URL must not be allowed to terminate the comment.
  • Loading branch information
stof committed Apr 27, 2022
1 parent 7004d49 commit 2ff1ad0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@

* Fix an issue where source locations tracked through variable references could
potentially become incorrect.
* Fix a bug where a loud comment in the source can break the source map when
embedding the sources, when using the command-line interface or the legacy JS
API.

## 1.51.0

Expand Down
4 changes: 3 additions & 1 deletion lib/src/executable/compile_stylesheet.dart
Expand Up @@ -174,6 +174,8 @@ String _writeSourceMap(
url = p.toUri(p.relative(sourceMapPath, from: p.dirname(destination)));
}

var escapedUrl = url.toString().replaceAll("*/", '%2A/');

return (options.style == OutputStyle.compressed ? '' : '\n\n') +
'/*# sourceMappingURL=$url */';
'/*# sourceMappingURL=$escapedUrl */';
}
3 changes: 2 additions & 1 deletion lib/src/node/legacy.dart
Expand Up @@ -405,7 +405,8 @@ RenderResult _newRenderResult(
: p.toUri(outFile == null
? sourceMapPath
: p.relative(sourceMapPath, from: p.dirname(outFile)));
css += "\n\n/*# sourceMappingURL=$url */";
var escapedUrl = url.toString().replaceAll("*/", '%2A/');
css += "\n\n/*# sourceMappingURL=$escapedUrl */";
}
}

Expand Down

0 comments on commit 2ff1ad0

Please sign in to comment.