Use a safe codec to read Skia SKP screenshot files when checking for errors (#14086)

If the downloaded file is an actual SKP and not an error report, then the
default UTF-8 codec will fail to decode the SKP content
This commit is contained in:
Jason Simmons 2018-01-12 17:54:49 -08:00 committed by GitHub
parent 27eeb9722f
commit e11cf5c94c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,7 +89,9 @@ class ScreenshotCommand extends FlutterCommand {
await sink.close();
await showOutputFileInfo(outputFile);
if (await outputFile.length() < 1000) {
final String content = await outputFile.readAsString();
final String content = await outputFile.readAsString(
encoding: const AsciiCodec(allowInvalid: true),
);
if (content.startsWith('{"jsonrpc":"2.0", "error"'))
throwToolExit('\nIt appears the output file contains an error message, not valid skia output.');
}