Unverified Commit 3bd4c69f authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Sanitize host before calling pm (#49591)" (#49623)

This reverts commit c592b546.
parent c592b546
......@@ -27,7 +27,6 @@ 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';
......@@ -514,7 +513,12 @@ class FuchsiaDevice extends Device {
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.
......
......@@ -10,7 +10,6 @@ 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 {
......@@ -110,9 +109,6 @@ 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',
......
// 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;
}
}
// 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 {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment