@@ -47,8 +47,10 @@ func TestTruncateName(t *testing.T) {
4747 {"base" , ".longextension" , 12 , "base.long" },
4848 {"exactfit" , ".jpeg" , 13 , "exactfit.jpeg" },
4949 {"longfilename" , ".txt" , 10 , "longfi.txt" },
50+ {"file" , ". . . long" , 12 , "file...lo" },
5051 {"truncatebase" , ".png" , 8 , "trun.png" },
5152 {"onlybase" , ".toolong" , 8 , "onl.tool" },
53+ {"test" , "test test" , 18 , "testtestt" },
5254 {"short" , ".dat" , 9 , "short.dat" },
5355 {"example" , "" , 5 , "examp" },
5456 {"" , ".zip" , 5 , ".zip" },
@@ -81,21 +83,29 @@ func TestSanitizeName(t *testing.T) {
8183 {"myfilenames" , extraChars , 10 , "myfilename" },
8284 {"@#$%^&*.png" , extraChars , 20 , defaultName },
8385 {"!@#$%^&*()[]{}<>" , extraChars , 20 , defaultName },
86+ {"!@# a copy.alongext" , extraChars , 20 , "a copy.alon" },
87+ {"<>$ a copy.m" , extraChars , 10 , "a copy.m" },
88+ {"a copy.my copy" , extraChars , 15 , "a copy.myco" },
8489 {"filename." , extraChars , 15 , "filename." },
8590 {"/etc/passwd" , extraChars , 15 , "passwd" },
8691 {"name\u0000 .txt" , extraChars , 20 , "name.txt" },
8792 {"control\t test.txt" , extraChars , 20 , "controltest.txt" },
8893 {"/path/../file.txt" , extraChars , 20 , "file.txt" },
8994 {"<script>alert('xss')</script>" , extraChars , 25 , "script" },
95+ {" " , extraChars , 15 , "default" },
9096 {"percent%encoded%name.doc" , extraChars , 20 , defaultName },
9197 {"filename%20with%20spaces.txt" , extraChars , 20 ,
9298 "filename with sp.txt" },
9399 {"filename with spaces.txt" , extraChars , 25 ,
94100 "filename with spaces.txt" },
95101 {"my%2Fcool%2Bdoc%26about%2Cstuff.md" , extraChars + "/+&," , 40 ,
96102 "cool+doc&about,stuff.md" },
103+ {"example." + strings .Repeat ("x" , 1000 ), extraChars , 20 ,
104+ "example.xxxx" },
97105 {strings .Repeat ("a" , 1000 ) + ".txt" , extraChars , 50 ,
98106 strings .Repeat ("a" , 46 ) + ".txt" },
107+ {strings .Repeat ("." , 100 ) + strings .Repeat ("." , 100 ), extraChars , 80 ,
108+ strings .Repeat ("." , 79 ) + "." },
99109 }
100110 for _ , test := range tests {
101111 t .Run (test .input , func (t * testing.T ) {
0 commit comments