Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: pkg/analyzer/test/src/dart/sdk/sdk_test.dart

Issue 2406353002: Validate patch file paths. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/dart/sdk/sdk_test.dart
diff --git a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
index 214bfa224dc59f06c7b621261b1064e24aa0c6fb..e684880503037e1f658d216c00e76978ebc5317a 100644
--- a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
@@ -527,6 +527,21 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
}, throwsArgumentError);
}
+ void test_readFrom_patches_invalid_path_hasDotDot() {
+ _assertPathIsInvalid('foo/../bar.dart');
+ _assertPathIsInvalid('../foo/bar.dart');
+ _assertPathIsInvalid('foo/bar..dart');
+ }
+
+ void test_readFrom_patches_invalid_path_isAbsolute() {
+ _assertPathIsInvalid('/foo.dart');
+ _assertPathIsInvalid('/foo/bar.dart');
+ }
+
+ void test_readFrom_patches_invalid_path_notPosix() {
+ _assertPathIsInvalid(r'foo\bar.dart');
+ }
+
void test_readFrom_patches_invalid_platformCombinator() {
expect(() {
new SdkLibrariesReader(false).readFromFile(
@@ -571,6 +586,20 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
expect(library.getPatches(SdkLibraryImpl.VM_PLATFORM), isEmpty);
expect(library.getPatches(SdkLibraryImpl.DART2JS_PLATFORM), isEmpty);
}
+
+ void _assertPathIsInvalid(String patchPath) {
+ expect(() {
+ new SdkLibrariesReader(false).readFromFile(
+ resourceProvider.getFile('/libs.dart'),
+ '''
+final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
+ 'foo' : const LibraryInfo(
+ 'foo/foo.dart',
+ patches: {
+ VM_PLATFORM: [r'$patchPath']}),
+};''');
+ }, throwsArgumentError);
+ }
}
@reflectiveTest
« pkg/analyzer/lib/src/generated/sdk.dart ('K') | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698