@@ -8,23 +8,29 @@ import (
8
8
"github.com/stretchr/testify/assert"
9
9
)
10
10
11
- func TestZip (t * testing.T ) {
12
- MkdirAll (`testdata` , os .ModePerm )
13
- n , err := Zip (`./encoding` , `testdata/test.zip` )
14
- assert .NoError (t , err )
15
- assert .NotEqual (t , n , 0 )
16
-
17
- err = Unzip (`testdata/test.zip` , `testdata/unarchive` )
18
- assert .NoError (t , err )
19
-
11
+ func TestIllegalFilePath (t * testing.T ) {
20
12
assert .Equal (t , `/a/b/c` , filepath .Dir (`/a/b/c/..a.txt` ))
21
13
assert .Equal (t , `/a/b` , filepath .Dir (`/a/b/c/../a.txt` ))
22
14
assert .Equal (t , `/abc/a/b/a.txt` , filepath .Join (`/abc` , `/a/b/c/../a.txt` ))
23
15
assert .Equal (t , `/abc/a\b\c\..\a.txt` , filepath .Join (`/abc` , `/a\b\c\..\a.txt` ))
24
16
assert .Equal (t , `/abc/a/b/c/..a.txt` , filepath .Join (`/abc` , `/a/b/c/..a.txt` ))
17
+ assert .Equal (t , `/a/b` , filepath .Join (`/a/b/c` , `..` ))
18
+ assert .Equal (t , `/a/b` , filepath .Join (`/a/b/c/..` ))
25
19
assert .True (t , IllegalFilePath (`a/b/c/../a.txt` ))
26
20
assert .True (t , IllegalFilePath (`a/b/c/..\a.txt` ))
27
21
assert .False (t , IllegalFilePath (`a/b/c/..a.txt` ))
22
+ assert .True (t , IllegalFilePath (`..` ))
23
+ assert .True (t , IllegalFilePath (`/..` ))
24
+ }
25
+
26
+ func TestZip (t * testing.T ) {
27
+ MkdirAll (`testdata` , os .ModePerm )
28
+ n , err := Zip (`./encoding` , `testdata/test.zip` )
29
+ assert .NoError (t , err )
30
+ assert .NotEqual (t , n , 0 )
31
+
32
+ err = Unzip (`testdata/test.zip` , `testdata/unarchive` )
33
+ assert .NoError (t , err )
28
34
}
29
35
30
36
func TestTarGz (t * testing.T ) {
0 commit comments