Show More
@@ -79,20 +79,24 b' class pathauditor(object):' | |||||
79 | return |
|
79 | return | |
80 | # AIX ignores "/" at end of path, others raise EISDIR. |
|
80 | # AIX ignores "/" at end of path, others raise EISDIR. | |
81 | if util.endswithsep(path): |
|
81 | if util.endswithsep(path): | |
82 | raise error.Abort(_(b"path ends in directory separator: %s") % path) |
|
82 | raise error.InputError( | |
|
83 | _(b"path ends in directory separator: %s") % path | |||
|
84 | ) | |||
83 | parts = util.splitpath(path) |
|
85 | parts = util.splitpath(path) | |
84 | if ( |
|
86 | if ( | |
85 | os.path.splitdrive(path)[0] |
|
87 | os.path.splitdrive(path)[0] | |
86 | or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'') |
|
88 | or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'') | |
87 | or pycompat.ospardir in parts |
|
89 | or pycompat.ospardir in parts | |
88 | ): |
|
90 | ): | |
89 | raise error.Abort(_(b"path contains illegal component: %s") % path) |
|
91 | raise error.InputError( | |
|
92 | _(b"path contains illegal component: %s") % path | |||
|
93 | ) | |||
90 | # Windows shortname aliases |
|
94 | # Windows shortname aliases | |
91 | for p in parts: |
|
95 | for p in parts: | |
92 | if b"~" in p: |
|
96 | if b"~" in p: | |
93 | first, last = p.split(b"~", 1) |
|
97 | first, last = p.split(b"~", 1) | |
94 | if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]: |
|
98 | if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]: | |
95 |
raise error. |
|
99 | raise error.InputError( | |
96 | _(b"path contains illegal component: %s") % path |
|
100 | _(b"path contains illegal component: %s") % path | |
97 | ) |
|
101 | ) | |
98 | if b'.hg' in _lowerclean(path): |
|
102 | if b'.hg' in _lowerclean(path): | |
@@ -101,7 +105,7 b' class pathauditor(object):' | |||||
101 | if p in lparts[1:]: |
|
105 | if p in lparts[1:]: | |
102 | pos = lparts.index(p) |
|
106 | pos = lparts.index(p) | |
103 | base = os.path.join(*parts[:pos]) |
|
107 | base = os.path.join(*parts[:pos]) | |
104 |
raise error. |
|
108 | raise error.InputError( | |
105 | _(b"path '%s' is inside nested repo %r") |
|
109 | _(b"path '%s' is inside nested repo %r") | |
106 | % (path, pycompat.bytestr(base)) |
|
110 | % (path, pycompat.bytestr(base)) | |
107 | ) |
|
111 | ) |
@@ -8,7 +8,7 b' audit of .hg' | |||||
8 |
|
8 | |||
9 | $ hg add .hg/00changelog.i |
|
9 | $ hg add .hg/00changelog.i | |
10 | abort: path contains illegal component: .hg/00changelog.i |
|
10 | abort: path contains illegal component: .hg/00changelog.i | |
11 |
[ |
|
11 | [10] | |
12 |
|
12 | |||
13 | #if symlink |
|
13 | #if symlink | |
14 |
|
14 | |||
@@ -91,7 +91,7 b' attack .hg/test' | |||||
91 | .hg/test |
|
91 | .hg/test | |
92 | $ hg update -Cr0 |
|
92 | $ hg update -Cr0 | |
93 | abort: path contains illegal component: .hg/test |
|
93 | abort: path contains illegal component: .hg/test | |
94 |
[ |
|
94 | [10] | |
95 |
|
95 | |||
96 | attack foo/.hg/test |
|
96 | attack foo/.hg/test | |
97 |
|
97 | |||
@@ -99,7 +99,7 b' attack foo/.hg/test' | |||||
99 | foo/.hg/test |
|
99 | foo/.hg/test | |
100 | $ hg update -Cr1 |
|
100 | $ hg update -Cr1 | |
101 | abort: path 'foo/.hg/test' is inside nested repo 'foo' |
|
101 | abort: path 'foo/.hg/test' is inside nested repo 'foo' | |
102 |
[ |
|
102 | [10] | |
103 |
|
103 | |||
104 | attack back/test where back symlinks to .. |
|
104 | attack back/test where back symlinks to .. | |
105 |
|
105 | |||
@@ -125,7 +125,7 b' attack ../test' | |||||
125 | $ echo data > ../test/file |
|
125 | $ echo data > ../test/file | |
126 | $ hg update -Cr3 |
|
126 | $ hg update -Cr3 | |
127 | abort: path contains illegal component: ../test |
|
127 | abort: path contains illegal component: ../test | |
128 |
[ |
|
128 | [10] | |
129 | $ cat ../test/file |
|
129 | $ cat ../test/file | |
130 | data |
|
130 | data | |
131 |
|
131 | |||
@@ -135,7 +135,7 b' attack /tmp/test' | |||||
135 | /tmp/test |
|
135 | /tmp/test | |
136 | $ hg update -Cr4 |
|
136 | $ hg update -Cr4 | |
137 | abort: path contains illegal component: /tmp/test |
|
137 | abort: path contains illegal component: /tmp/test | |
138 |
[ |
|
138 | [10] | |
139 |
|
139 | |||
140 | $ cd .. |
|
140 | $ cd .. | |
141 |
|
141 |
@@ -10,7 +10,7 b' on commit:' | |||||
10 | $ echo 'sub/.hg = sub/.hg' >> .hgsub |
|
10 | $ echo 'sub/.hg = sub/.hg' >> .hgsub | |
11 | $ hg ci -qAm 'add subrepo "sub/.hg"' |
|
11 | $ hg ci -qAm 'add subrepo "sub/.hg"' | |
12 | abort: path 'sub/.hg' is inside nested repo 'sub' |
|
12 | abort: path 'sub/.hg' is inside nested repo 'sub' | |
13 |
[ |
|
13 | [10] | |
14 |
|
14 | |||
15 | prepare tampered repo (including the commit above): |
|
15 | prepare tampered repo (including the commit above): | |
16 |
|
16 | |||
@@ -34,7 +34,7 b' on clone (and update):' | |||||
34 |
|
34 | |||
35 | $ hg clone -q hgname hgname2 |
|
35 | $ hg clone -q hgname hgname2 | |
36 | abort: path 'sub/.hg' is inside nested repo 'sub' |
|
36 | abort: path 'sub/.hg' is inside nested repo 'sub' | |
37 |
[ |
|
37 | [10] | |
38 |
|
38 | |||
39 | Test absolute path |
|
39 | Test absolute path | |
40 | ------------------ |
|
40 | ------------------ | |
@@ -47,7 +47,7 b' on commit:' | |||||
47 | $ echo '/sub = sub' >> .hgsub |
|
47 | $ echo '/sub = sub' >> .hgsub | |
48 | $ hg ci -qAm 'add subrepo "/sub"' |
|
48 | $ hg ci -qAm 'add subrepo "/sub"' | |
49 | abort: path contains illegal component: /sub |
|
49 | abort: path contains illegal component: /sub | |
50 |
[ |
|
50 | [10] | |
51 |
|
51 | |||
52 | prepare tampered repo (including the commit above): |
|
52 | prepare tampered repo (including the commit above): | |
53 |
|
53 | |||
@@ -71,7 +71,7 b' on clone (and update):' | |||||
71 |
|
71 | |||
72 | $ hg clone -q absolutepath absolutepath2 |
|
72 | $ hg clone -q absolutepath absolutepath2 | |
73 | abort: path contains illegal component: /sub |
|
73 | abort: path contains illegal component: /sub | |
74 |
[ |
|
74 | [10] | |
75 |
|
75 | |||
76 | Test root path |
|
76 | Test root path | |
77 | -------------- |
|
77 | -------------- | |
@@ -84,7 +84,7 b' on commit:' | |||||
84 | $ echo '/ = sub' >> .hgsub |
|
84 | $ echo '/ = sub' >> .hgsub | |
85 | $ hg ci -qAm 'add subrepo "/"' |
|
85 | $ hg ci -qAm 'add subrepo "/"' | |
86 | abort: path ends in directory separator: / |
|
86 | abort: path ends in directory separator: / | |
87 |
[ |
|
87 | [10] | |
88 |
|
88 | |||
89 | prepare tampered repo (including the commit above): |
|
89 | prepare tampered repo (including the commit above): | |
90 |
|
90 | |||
@@ -108,7 +108,7 b' on clone (and update):' | |||||
108 |
|
108 | |||
109 | $ hg clone -q rootpath rootpath2 |
|
109 | $ hg clone -q rootpath rootpath2 | |
110 | abort: path ends in directory separator: / |
|
110 | abort: path ends in directory separator: / | |
111 |
[ |
|
111 | [10] | |
112 |
|
112 | |||
113 | Test empty path |
|
113 | Test empty path | |
114 | --------------- |
|
114 | --------------- | |
@@ -197,7 +197,7 b' on commit:' | |||||
197 | $ echo '../sub = ../sub' >> .hgsub |
|
197 | $ echo '../sub = ../sub' >> .hgsub | |
198 | $ hg ci -qAm 'add subrepo "../sub"' |
|
198 | $ hg ci -qAm 'add subrepo "../sub"' | |
199 | abort: path contains illegal component: ../sub |
|
199 | abort: path contains illegal component: ../sub | |
200 |
[ |
|
200 | [10] | |
201 |
|
201 | |||
202 | prepare tampered repo (including the commit above): |
|
202 | prepare tampered repo (including the commit above): | |
203 |
|
203 | |||
@@ -221,7 +221,7 b' on clone (and update):' | |||||
221 |
|
221 | |||
222 | $ hg clone -q main main2 |
|
222 | $ hg clone -q main main2 | |
223 | abort: path contains illegal component: ../sub |
|
223 | abort: path contains illegal component: ../sub | |
224 |
[ |
|
224 | [10] | |
225 | $ cd .. |
|
225 | $ cd .. | |
226 |
|
226 | |||
227 | Test variable expansion |
|
227 | Test variable expansion | |
@@ -718,7 +718,7 b' on clone (and update):' | |||||
718 |
|
718 | |||
719 | $ hg clone -q driveletter driveletter2 |
|
719 | $ hg clone -q driveletter driveletter2 | |
720 | abort: path contains illegal component: X: |
|
720 | abort: path contains illegal component: X: | |
721 |
[ |
|
721 | [10] | |
722 |
|
722 | |||
723 | #else |
|
723 | #else | |
724 |
|
724 |
@@ -661,11 +661,11 b' verify pathauditor blocks evil filepaths' | |||||
661 | #if windows |
|
661 | #if windows | |
662 | $ hg co --clean tip |
|
662 | $ hg co --clean tip | |
663 | abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc) |
|
663 | abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc) | |
664 |
[ |
|
664 | [10] | |
665 | #else |
|
665 | #else | |
666 | $ hg co --clean tip |
|
666 | $ hg co --clean tip | |
667 | abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc) |
|
667 | abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc) | |
668 |
[ |
|
668 | [10] | |
669 | #endif |
|
669 | #endif | |
670 |
|
670 | |||
671 | $ hg rollback -f |
|
671 | $ hg rollback -f | |
@@ -686,7 +686,7 b' verify pathauditor blocks evil filepaths' | |||||
686 | $ "$PYTHON" evil-commit.py |
|
686 | $ "$PYTHON" evil-commit.py | |
687 | $ hg co --clean tip |
|
687 | $ hg co --clean tip | |
688 | abort: path contains illegal component: HG~1/hgrc |
|
688 | abort: path contains illegal component: HG~1/hgrc | |
689 |
[ |
|
689 | [10] | |
690 |
|
690 | |||
691 | $ hg rollback -f |
|
691 | $ hg rollback -f | |
692 | repository tip rolled back to revision 2 (undo commit) |
|
692 | repository tip rolled back to revision 2 (undo commit) | |
@@ -706,7 +706,7 b' verify pathauditor blocks evil filepaths' | |||||
706 | $ "$PYTHON" evil-commit.py |
|
706 | $ "$PYTHON" evil-commit.py | |
707 | $ hg co --clean tip |
|
707 | $ hg co --clean tip | |
708 | abort: path contains illegal component: HG8B6C~2/hgrc |
|
708 | abort: path contains illegal component: HG8B6C~2/hgrc | |
709 |
[ |
|
709 | [10] | |
710 |
|
710 | |||
711 | $ cd .. |
|
711 | $ cd .. | |
712 |
|
712 |
@@ -1085,7 +1085,7 b' test paths outside repo root' | |||||
1085 | > EOF |
|
1085 | > EOF | |
1086 | applying patch from stdin |
|
1086 | applying patch from stdin | |
1087 | abort: path contains illegal component: ../outside/foo |
|
1087 | abort: path contains illegal component: ../outside/foo | |
1088 |
[ |
|
1088 | [10] | |
1089 | $ cd .. |
|
1089 | $ cd .. | |
1090 |
|
1090 | |||
1091 |
|
1091 |
@@ -610,7 +610,7 b' check illegal path components' | |||||
610 |
|
610 | |||
611 | $ hg rename d1/d11/a1 .hg/foo |
|
611 | $ hg rename d1/d11/a1 .hg/foo | |
612 | abort: path contains illegal component: .hg/foo |
|
612 | abort: path contains illegal component: .hg/foo | |
613 |
[ |
|
613 | [10] | |
614 | $ hg status -C |
|
614 | $ hg status -C | |
615 | $ hg rename d1/d11/a1 ../foo |
|
615 | $ hg rename d1/d11/a1 ../foo | |
616 | abort: ../foo not under root '$TESTTMP' |
|
616 | abort: ../foo not under root '$TESTTMP' | |
@@ -620,7 +620,7 b' check illegal path components' | |||||
620 | $ mv d1/d11/a1 .hg/foo |
|
620 | $ mv d1/d11/a1 .hg/foo | |
621 | $ hg rename --after d1/d11/a1 .hg/foo |
|
621 | $ hg rename --after d1/d11/a1 .hg/foo | |
622 | abort: path contains illegal component: .hg/foo |
|
622 | abort: path contains illegal component: .hg/foo | |
623 |
[ |
|
623 | [10] | |
624 | $ hg status -C |
|
624 | $ hg status -C | |
625 | ! d1/d11/a1 |
|
625 | ! d1/d11/a1 | |
626 | $ hg update -C |
|
626 | $ hg update -C | |
@@ -629,11 +629,11 b' check illegal path components' | |||||
629 |
|
629 | |||
630 | $ hg rename d1/d11/a1 .hg |
|
630 | $ hg rename d1/d11/a1 .hg | |
631 | abort: path contains illegal component: .hg/a1 |
|
631 | abort: path contains illegal component: .hg/a1 | |
632 |
[ |
|
632 | [10] | |
633 | $ hg --config extensions.largefiles= rename d1/d11/a1 .hg |
|
633 | $ hg --config extensions.largefiles= rename d1/d11/a1 .hg | |
634 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
|
634 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) | |
635 | abort: path contains illegal component: .hg/a1 |
|
635 | abort: path contains illegal component: .hg/a1 | |
636 |
[ |
|
636 | [10] | |
637 | $ hg status -C |
|
637 | $ hg status -C | |
638 | $ hg rename d1/d11/a1 .. |
|
638 | $ hg rename d1/d11/a1 .. | |
639 | abort: ../a1 not under root '$TESTTMP' |
|
639 | abort: ../a1 not under root '$TESTTMP' | |
@@ -647,7 +647,7 b' check illegal path components' | |||||
647 | $ mv d1/d11/a1 .hg |
|
647 | $ mv d1/d11/a1 .hg | |
648 | $ hg rename --after d1/d11/a1 .hg |
|
648 | $ hg rename --after d1/d11/a1 .hg | |
649 | abort: path contains illegal component: .hg/a1 |
|
649 | abort: path contains illegal component: .hg/a1 | |
650 |
[ |
|
650 | [10] | |
651 | $ hg status -C |
|
651 | $ hg status -C | |
652 | ! d1/d11/a1 |
|
652 | ! d1/d11/a1 | |
653 | $ hg update -C |
|
653 | $ hg update -C | |
@@ -656,7 +656,7 b' check illegal path components' | |||||
656 |
|
656 | |||
657 | $ (cd d1/d11; hg rename ../../d2/b ../../.hg/foo) |
|
657 | $ (cd d1/d11; hg rename ../../d2/b ../../.hg/foo) | |
658 | abort: path contains illegal component: .hg/foo |
|
658 | abort: path contains illegal component: .hg/foo | |
659 |
[ |
|
659 | [10] | |
660 | $ hg status -C |
|
660 | $ hg status -C | |
661 | $ (cd d1/d11; hg rename ../../d2/b ../../../foo) |
|
661 | $ (cd d1/d11; hg rename ../../d2/b ../../../foo) | |
662 | abort: ../../../foo not under root '$TESTTMP' |
|
662 | abort: ../../../foo not under root '$TESTTMP' |
@@ -299,10 +299,10 b'' | |||||
299 | f mammals/skunk skunk |
|
299 | f mammals/skunk skunk | |
300 | $ hg debugwalk -v .hg |
|
300 | $ hg debugwalk -v .hg | |
301 | abort: path 'mammals/.hg' is inside nested repo 'mammals' |
|
301 | abort: path 'mammals/.hg' is inside nested repo 'mammals' | |
302 |
[ |
|
302 | [10] | |
303 | $ hg debugwalk -v ../.hg |
|
303 | $ hg debugwalk -v ../.hg | |
304 | abort: path contains illegal component: .hg |
|
304 | abort: path contains illegal component: .hg | |
305 |
[ |
|
305 | [10] | |
306 | $ cd .. |
|
306 | $ cd .. | |
307 |
|
307 | |||
308 | $ hg debugwalk -v -Ibeans |
|
308 | $ hg debugwalk -v -Ibeans | |
@@ -410,16 +410,16 b'' | |||||
410 | [255] |
|
410 | [255] | |
411 | $ hg debugwalk -v .hg |
|
411 | $ hg debugwalk -v .hg | |
412 | abort: path contains illegal component: .hg |
|
412 | abort: path contains illegal component: .hg | |
413 |
[ |
|
413 | [10] | |
414 | $ hg debugwalk -v beans/../.hg |
|
414 | $ hg debugwalk -v beans/../.hg | |
415 | abort: path contains illegal component: .hg |
|
415 | abort: path contains illegal component: .hg | |
416 |
[ |
|
416 | [10] | |
417 | $ hg debugwalk -v beans/../.hg/data |
|
417 | $ hg debugwalk -v beans/../.hg/data | |
418 | abort: path contains illegal component: .hg/data |
|
418 | abort: path contains illegal component: .hg/data | |
419 |
[ |
|
419 | [10] | |
420 | $ hg debugwalk -v beans/.hg |
|
420 | $ hg debugwalk -v beans/.hg | |
421 | abort: path 'beans/.hg' is inside nested repo 'beans' |
|
421 | abort: path 'beans/.hg' is inside nested repo 'beans' | |
422 |
[ |
|
422 | [10] | |
423 |
|
423 | |||
424 | Test explicit paths and excludes: |
|
424 | Test explicit paths and excludes: | |
425 |
|
425 |
General Comments 0
You need to be logged in to leave comments.
Login now