3
Origin: c02a05cc6f5e661b09b0b0c65ec7bc874e161f9c (backport)
5
# User Augie Fackler <raf@durin42.com>
6
# Date 1418753297 18000
7
# Node ID c02a05cc6f5e661b09b0b0c65ec7bc874e161f9c
8
# Parent 7a5bcd471f2ef302613b8551a79081d46d04be6e
9
pathauditor: check for codepoints ignored on OS X
11
Index: mercurial-2.8.2/mercurial/scmutil.py
12
===================================================================
13
--- mercurial-2.8.2.orig/mercurial/scmutil.py
14
+++ mercurial-2.8.2/mercurial/scmutil.py
16
# This software may be used and distributed according to the terms of the
17
# GNU General Public License version 2 or any later version.
21
from mercurial.node import nullrev
22
import util, error, osutil, revset, similar, encoding, phases, parsers
23
@@ -19,6 +20,9 @@ else:
24
systemrcpath = scmplatform.systemrcpath
25
userrcpath = scmplatform.userrcpath
28
+ return encoding.hfsignoreclean(s.lower())
30
def nochangesfound(ui, repo, excluded=None):
31
'''Report no changes for push/pull, excluded is None or a list of
32
nodes excluded from the push/pull.
33
@@ -143,11 +147,11 @@ class pathauditor(object):
34
raise util.Abort(_("path ends in directory separator: %s") % path)
35
parts = util.splitpath(path)
36
if (os.path.splitdrive(path)[0]
37
- or parts[0].lower() in ('.hg', '.hg.', '')
38
+ or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
39
or os.pardir in parts):
40
raise util.Abort(_("path contains illegal component: %s") % path)
41
- if '.hg' in path.lower():
42
- lparts = [p.lower() for p in parts]
43
+ if '.hg' in _lowerclean(path):
44
+ lparts = [_lowerclean(p.lower()) for p in parts]
45
for p in '.hg', '.hg.':
48
Index: mercurial-2.8.2/tests/test-commit.t
49
===================================================================
50
--- mercurial-2.8.2.orig/tests/test-commit.t
51
+++ mercurial-2.8.2/tests/test-commit.t
52
@@ -306,4 +306,21 @@ commit copy
53
0 0 6 ..... 0 26d3ca0dfd18 000000000000 000000000000 (re)
54
1 6 7 ..... 1 d267bddd54f7 26d3ca0dfd18 000000000000 (re)
56
+verify pathauditor blocks evil filepaths
57
+ $ cat > evil-commit.py <<EOF
58
+ > from mercurial import ui, hg, context, node
59
+ > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
61
+ > r = hg.repository(u, '.')
62
+ > def filectxfn(repo, memctx, path):
63
+ > return context.memfilectx(path, '[hooks]\nupdate = echo owned')
64
+ > c = context.memctx(r, [r['tip'].node(), node.nullid],
65
+ > 'evil', [notrc], filectxfn, 0)
68
+ $ $PYTHON evil-commit.py
70
+ abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc)