Merge pull request #12278 from heijian123/main

Fix helm may identify achieve of the application/x-gzip as application/vnd.ms-fontobject
pull/12256/head
Joe Julian 1 year ago committed by GitHub
commit f9e03f196d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -85,7 +85,10 @@ func ensureArchive(name string, raw *os.File) error {
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
return fmt.Errorf("file '%s' cannot be read: %s", name, err) return fmt.Errorf("file '%s' cannot be read: %s", name, err)
} }
if contentType := http.DetectContentType(buffer); contentType != "application/x-gzip" {
// Helm may identify achieve of the application/x-gzip as application/vnd.ms-fontobject.
// Fix for: https://github.com/helm/helm/issues/12261
if contentType := http.DetectContentType(buffer); contentType != "application/x-gzip" && !isGZipApplication(buffer) {
// TODO: Is there a way to reliably test if a file content is YAML? ghodss/yaml accepts a wide // TODO: Is there a way to reliably test if a file content is YAML? ghodss/yaml accepts a wide
// variety of content (Makefile, .zshrc) as valid YAML without errors. // variety of content (Makefile, .zshrc) as valid YAML without errors.
@ -98,6 +101,12 @@ func ensureArchive(name string, raw *os.File) error {
return nil return nil
} }
// isGZipApplication checks whether the achieve is of the application/x-gzip type.
func isGZipApplication(data []byte) bool {
sig := []byte("\x1F\x8B\x08")
return bytes.HasPrefix(data, sig)
}
// LoadArchiveFiles reads in files out of an archive into memory. This function // LoadArchiveFiles reads in files out of an archive into memory. This function
// performs important path security checks and should always be used before // performs important path security checks and should always be used before
// expanding a tarball // expanding a tarball

Loading…
Cancel
Save