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
This commit is contained in:
Colin Cross 2021-02-03 15:15:14 -08:00
parent 801a669566
commit caf4d4c270
2 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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),
},
},
{