Skip to content

Wrap dart:convert to track utf8 decode failures#26650

Merged
jonahwilliams merged 7 commits into
flutter:masterfrom
jonahwilliams:utf8_fixer
Jan 26, 2019
Merged

Wrap dart:convert to track utf8 decode failures#26650
jonahwilliams merged 7 commits into
flutter:masterfrom
jonahwilliams:utf8_fixer

Conversation

@jonahwilliams

@jonahwilliams jonahwilliams commented Jan 16, 2019

Copy link
Copy Markdown
Contributor

Creates a tools specific implementation of Utf8Decoder that allows malformed utf8 and then checks for \u{FFFD}. If that is encountered, an error is thrown with more context.

Adds an unauthorized imports test to cover the flutter_tools lib directory.

#15646

@jonahwilliams

Copy link
Copy Markdown
Contributor Author

cc @Hixie

@zoechi zoechi added the tool Affects the "flutter" command-line tool. See also t: labels. label Jan 16, 2019
@zoechi zoechi changed the title Wrap dart:covnert to track utf8 decode failures Wrap dart:convert to track utf8 decode failures Jan 17, 2019
runCommand(device.adbCommandForDevice(args)).then<void>((Process process) {
_process = process;
const Utf8Decoder decoder = Utf8Decoder(allowMalformed: true);
// Previously this line specified allowMalformed: true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid "history of the code" comments. Maybe explain why reportErrors is true, instead.

process.stdin.write('n\n');
final Future<void> output = process.stdout
.transform<String>(const Utf8Decoder(allowMalformed: true))
// Previously this line specified allowMalformed: true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto here and below.

@@ -0,0 +1,47 @@
// Copyright 2018 The Chromium Authors. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:convert' hide utf8;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! Maybe add a comment here explaining what this does.

@jonahwilliams jonahwilliams merged commit 91fd89e into flutter:master Jan 26, 2019
kangwang1988 pushed a commit to XianyuTech/flutter that referenced this pull request Feb 12, 2019
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants