Sanitize host before calling pm (#49591)

This commit is contained in:
Emmanuel Garcia
2020-01-28 08:17:11 -08:00
committed by GitHub
parent 68ed5c2baf
commit c592b54678
4 changed files with 99 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ import 'application_package.dart';
import 'fuchsia_build.dart';
import 'fuchsia_pm.dart';
import 'fuchsia_sdk.dart';
import 'fuchsia_utils.dart';
import 'fuchsia_workflow.dart';
import 'tiles_ctl.dart';
@@ -513,12 +514,7 @@ class FuchsiaDevice extends Device {
void clearLogs() {}
bool get ipv6 {
try {
Uri.parseIPv6Address(id);
return true;
} on FormatException {
return false;
}
return isIPv6Address(id);
}
/// List the ports currently running a dart observatory.

View File

@@ -10,6 +10,7 @@ import '../convert.dart';
import '../globals.dart' as globals;
import 'fuchsia_sdk.dart';
import 'fuchsia_utils.dart';
/// This is a basic wrapper class for the Fuchsia SDK's `pm` tool.
class FuchsiaPM {
@@ -109,6 +110,9 @@ class FuchsiaPM {
if (fuchsiaArtifacts.pm == null) {
throwToolExit('Fuchsia pm tool not found');
}
if (isIPv6Address(host.split('%').first)) {
host = '[${host.replaceAll('%', '%25')}]';
}
final List<String> command = <String>[
fuchsiaArtifacts.pm.path,
'serve',

View File

@@ -0,0 +1,13 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Returns [true] if [address] is an IPv6 address.
bool isIPv6Address(String address) {
try {
Uri.parseIPv6Address(address);
return true;
} on FormatException {
return false;
}
}