Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape the source map URL before using it in a CSS comment #1676

Merged
merged 1 commit into from Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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