Mercurial > hg
comparison tests/test-dirs.py @ 43494:5d40317d42b7
dirs: reject consecutive slashes in paths
We shouldn't ever see those, and the fuzzer go really excited that if
it gives us a 65k string with 55k slashes in it we use a lot of RAM.
This is a better fix than what I tried in D7105. It was suggested by
Yuya, and I verified it does in fact cause the fuzzer to not OOM.
This is a revision of D7234, but with the missing set of an error
added. I added a unit test of the dirs behavior because I needed to
reason more carefully about the failure modes around consecutive
slashes.
Differential Revision: https://phab.mercurial-scm.org/D7252
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 17 Oct 2019 19:29:22 -0400 |
parents | |
children | c21aca51b392 |
comparison
equal
deleted
inserted
replaced
43493:3a463e5e470b | 43494:5d40317d42b7 |
---|---|
1 from __future__ import absolute_import | |
2 | |
3 import unittest | |
4 | |
5 import silenttestrunner | |
6 | |
7 from mercurial import util | |
8 | |
9 | |
10 class dirstests(unittest.TestCase): | |
11 def testdirs(self): | |
12 for case, want in [ | |
13 (b'a/a/a', [b'a', b'a/a', b'']), | |
14 (b'alpha/beta/gamma', [b'', b'alpha', b'alpha/beta']), | |
15 ]: | |
16 d = util.dirs({}) | |
17 d.addpath(case) | |
18 self.assertEqual(sorted(d), sorted(want)) | |
19 | |
20 def testinvalid(self): | |
21 with self.assertRaises(ValueError): | |
22 d = util.dirs({}) | |
23 d.addpath(b'a//b') | |
24 | |
25 | |
26 if __name__ == '__main__': | |
27 silenttestrunner.main(__name__) |