summaryrefslogtreecommitdiff
path: root/zip
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2021-02-03 15:15:14 -0800
committer Colin Cross <ccross@android.com> 2021-02-03 16:06:20 -0800
commitcaf4d4c270b2f72fc75f13d25544ecb35514b523 (patch)
tree27aa5b8d3c118ca2c54747cc5313918ceaf95ece /zip
parent801a6695664a0ff167cc306ac612f79d893f04e5 (diff)
soong_zip: don't glob RSP file entries
File arguments are considered globs, but RSP file entries should be considered filenames without globbing. Escape RSP file entries so they don't get treated as globs later. Bug: 179297188 Test: zip_test.go Change-Id: I1de7829c668538204fc4a2ac793a4f88dbc886c9
Diffstat (limited to 'zip')
-rw-r--r--zip/zip.go3
-rw-r--r--zip/zip_test.go14
2 files changed, 13 insertions, 4 deletions
diff --git a/zip/zip.go b/zip/zip.go
index cb85f5ced..f7313291c 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -172,6 +172,9 @@ func (b *FileArgsBuilder) RspFile(name string) *FileArgsBuilder {
arg := b.state
arg.SourceFiles = ReadRespFile(list)
+ for i := range arg.SourceFiles {
+ arg.SourceFiles[i] = pathtools.MatchEscape(arg.SourceFiles[i])
+ }
b.fileArgs = append(b.fileArgs, arg)
return b
}
diff --git a/zip/zip_test.go b/zip/zip_test.go
index a16e09286..b456ef8f2 100644
--- a/zip/zip_test.go
+++ b/zip/zip_test.go
@@ -46,13 +46,14 @@ var mockFs = pathtools.MockFs(map[string][]byte{
"dangling -> missing": nil,
"a/a/d -> b": nil,
"c": fileC,
- "l_nl": []byte("a/a/a\na/a/b\nc\n"),
- "l_sp": []byte("a/a/a a/a/b c"),
+ "l_nl": []byte("a/a/a\na/a/b\nc\n\\[\n"),
+ "l_sp": []byte("a/a/a a/a/b c \\["),
"l2": []byte("missing\n"),
- "rsp": []byte("'a/a/a'\na/a/b\n'@'\n'foo'\\''bar'"),
+ "rsp": []byte("'a/a/a'\na/a/b\n'@'\n'foo'\\''bar'\n'['"),
"@ -> c": nil,
"foo'bar -> c": nil,
"manifest.txt": fileCustomManifest,
+ "[": fileEmpty,
})
func fh(name string, contents []byte, method uint16) zip.FileHeader {
@@ -127,13 +128,15 @@ func TestZip(t *testing.T) {
args: fileArgsBuilder().
File("a/a/a").
File("a/a/b").
- File("c"),
+ File("c").
+ File(`\[`),
compressionLevel: 9,
files: []zip.FileHeader{
fh("a/a/a", fileA, zip.Deflate),
fh("a/a/b", fileB, zip.Deflate),
fh("c", fileC, zip.Deflate),
+ fh("[", fileEmpty, zip.Store),
},
},
{
@@ -235,6 +238,7 @@ func TestZip(t *testing.T) {
fh("a/a/a", fileA, zip.Deflate),
fh("a/a/b", fileB, zip.Deflate),
fh("c", fileC, zip.Deflate),
+ fh("[", fileEmpty, zip.Store),
},
},
{
@@ -247,6 +251,7 @@ func TestZip(t *testing.T) {
fh("a/a/a", fileA, zip.Deflate),
fh("a/a/b", fileB, zip.Deflate),
fh("c", fileC, zip.Deflate),
+ fh("[", fileEmpty, zip.Store),
},
},
{
@@ -260,6 +265,7 @@ func TestZip(t *testing.T) {
fh("a/a/b", fileB, zip.Deflate),
fh("@", fileC, zip.Deflate),
fh("foo'bar", fileC, zip.Deflate),
+ fh("[", fileEmpty, zip.Store),
},
},
{