From 769f0dd9ccb70a3def5834e4a37c00110fbcb068 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" <lrn@google.com> Date: Fri, 20 Jul 2018 15:42:12 +0200 Subject: [PATCH] Strengthen UTF-8 decoding. (#911) Decoding input bytes by doing `.map(utf8.decode)` assumes that input byte chunks are split at encoded code-unit boundaries. It's safer to use `.transform(utf8.decoder)` which allows encodings to be split accross input chunks. Also changed `.listen(f).asFuture()` to the equivalent `.forEach(f)`. --- lib/src/runner/compiler_pool.dart | 4 ++-- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/runner/compiler_pool.dart b/lib/src/runner/compiler_pool.dart index da4b0aa4..13d75b3c 100644 --- a/lib/src/runner/compiler_pool.dart +++ b/lib/src/runner/compiler_pool.dart @@ -90,8 +90,8 @@ class CompilerPool { var buffer = new StringBuffer(); await Future.wait([ - process.stdout.map(utf8.decode).listen(buffer.write).asFuture(), - process.stderr.map(utf8.decode).listen(buffer.write).asFuture(), + process.stdout.transform(utf8.decoder).forEach(buffer.write), + process.stderr.transform(utf8.decoder).forEach(buffer.write), ]); var exitCode = await process.exitCode; diff --git a/pubspec.yaml b/pubspec.yaml index 6bcfa560..b4710542 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 1.3.0 +version: 1.3.1-dev author: Dart Team <misc@dartlang.org> description: A library for writing dart unit tests. homepage: https://github.com/dart-lang/test -- GitLab