Unverified Commit 2aa90166 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] ensure etag headers are ascii (#55704)

parent 34b8f830
......@@ -350,7 +350,8 @@ class WebAssetServer implements AssetReader {
// For real files, use a serialized file stat plus path as a revision.
// This allows us to update between canvaskit and non-canvaskit SDKs.
final String etag = file.lastModifiedSync().toIso8601String() + file.path;
final String etag = file.lastModifiedSync().toIso8601String()
+ Uri.encodeComponent(file.path);
if (ifNoneMatch == etag) {
return shelf.Response.notModified();
}
......
......@@ -324,6 +324,18 @@ void main() {
expect((await response.read().toList()).first, source.readAsBytesSync());
}));
test('serves valid etag header for asset files with non-ascii chracters', () => testbed.run(() async {
globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'fooπ'))
..createSync(recursive: true)
..writeAsBytesSync(<int>[1, 2, 3]);
final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/fooπ')));
final String etag = response.headers[HttpHeaders.etagHeader];
expect(etag.runes, everyElement(predicate((int char) => char < 255)));
}));
test('handles serving missing asset file', () => testbed.run(() async {
final Response response = await webAssetServer
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/foo')));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment