Revert "Sanitize host before calling pm (#49591)" (#49623)
This reverts commit c592b5467868b2f3769dd9db63425e5fa4e949a1.
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
index 4e8e6f1..644bbb0 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
@@ -27,7 +27,6 @@
import 'fuchsia_build.dart';
import 'fuchsia_pm.dart';
import 'fuchsia_sdk.dart';
-import 'fuchsia_utils.dart';
import 'fuchsia_workflow.dart';
import 'tiles_ctl.dart';
@@ -514,7 +513,12 @@
void clearLogs() {}
bool get ipv6 {
- return isIPv6Address(id);
+ try {
+ Uri.parseIPv6Address(id);
+ return true;
+ } on FormatException {
+ return false;
+ }
}
/// List the ports currently running a dart observatory.
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
index d8ca646..9400470 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
@@ -10,7 +10,6 @@
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 {
@@ -110,9 +109,6 @@
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',
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_utils.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_utils.dart
deleted file mode 100644
index af25998..0000000
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_utils.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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;
- }
-}
diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart
deleted file mode 100644
index a4d3d8d..0000000
--- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-// 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.
-
-import 'dart:async';
-
-import 'package:flutter_tools/src/base/context.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/process.dart';
-import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart';
-import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
-import 'package:mockito/mockito.dart';
-
-import '../../src/common.dart';
-import '../../src/context.dart';
-import '../../src/mocks.dart';
-
-void main() {
- group('FuchsiaPM', () {
- MockFile pm;
- MockProcessUtils mockProcessUtils;
- MockFuchsiaArtifacts mockFuchsiaArtifacts;
-
- setUp(() {
- pm = MockFile();
- when(pm.path).thenReturn('pm');
-
- mockFuchsiaArtifacts = MockFuchsiaArtifacts();
- when(mockFuchsiaArtifacts.pm).thenReturn(pm);
-
- mockProcessUtils = MockProcessUtils();
- });
-
- testUsingContext('serve - IPv4 address', () async {
- when(mockProcessUtils.start(any)).thenAnswer((_) {
- return Future<Process>.value(createMockProcess());
- });
-
- await FuchsiaPM().serve('<repo>', '127.0.0.1', 43819);
-
- verify(mockProcessUtils.start(<String>[
- 'pm',
- 'serve',
- '-repo',
- '<repo>',
- '-l',
- '127.0.0.1:43819',
- ])).called(1);
- }, overrides: <Type, Generator>{
- FuchsiaArtifacts: () => mockFuchsiaArtifacts,
- ProcessUtils: () => mockProcessUtils,
- });
-
- testUsingContext('serve - IPv6 address', () async {
- when(mockProcessUtils.start(any)).thenAnswer((_) {
- return Future<Process>.value(createMockProcess());
- });
-
- await FuchsiaPM().serve('<repo>', 'fe80::ec4:7aff:fecc:ea8f%eno2', 43819);
-
- verify(mockProcessUtils.start(<String>[
- 'pm',
- 'serve',
- '-repo',
- '<repo>',
- '-l',
- '[fe80::ec4:7aff:fecc:ea8f%25eno2]:43819',
- ])).called(1);
- }, overrides: <Type, Generator>{
- FuchsiaArtifacts: () => mockFuchsiaArtifacts,
- ProcessUtils: () => mockProcessUtils,
- });
- });
-}
-
-class MockFuchsiaArtifacts extends Mock implements FuchsiaArtifacts {}
-class MockProcessUtils extends Mock implements ProcessUtils {}
-class MockFile extends Mock implements File {}
-class MockProcess extends Mock implements Process {}