diff tests/test-narrow-patterns.t @ 39531:0d572769046a

narrowspec: limit patterns to path: and rootfilesin: (BC) Some matcher patterns are computationally expensive and may even have security issues (e.g. evaluating some file sets). For these reasons, we want to limit the types of matcher patterns that can be used in narrow specs and by command line arguments used for defining narrow specs. This commit teaches ``narrowspec.parsepatterns()`` to validate the pattern types against "safe" patterns. Surprisingly, no existing tests broke. So tests for the feature have been added. We also added a function to validate a patterns data structure. This will be used in future commits. Differential Revision: https://phab.mercurial-scm.org/D4522
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 11 Sep 2018 15:25:35 -0700
parents fa64a229f24b
children 8d8e61df8259
line wrap: on
line diff
--- a/tests/test-narrow-patterns.t	Tue Sep 11 10:54:20 2018 -0700
+++ b/tests/test-narrow-patterns.t	Tue Sep 11 15:25:35 2018 -0700
@@ -427,3 +427,15 @@
   |
   o  0 2a4f0c3b67da... root
   
+
+Illegal patterns are rejected
+
+  $ hg tracked --addinclude glob:**
+  abort: invalid prefix on narrow pattern: glob:**
+  (narrow patterns must begin with one of the following: path:, rootfilesin:)
+  [255]
+
+  $ hg tracked --addexclude set:ignored
+  abort: invalid prefix on narrow pattern: set:ignored
+  (narrow patterns must begin with one of the following: path:, rootfilesin:)
+  [255]