Parcourir la source

Implement the fix for a file with no sharedStrings.xml as proposed by
HeinOldewage.

Geoffrey J. Teale il y a 11 ans
Parent
commit
0f709e079c
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      lib.go

+ 7 - 0
lib.go

@@ -629,6 +629,13 @@ func readSharedStringsFromZipFile(f *zip.File) ([]string, error) {
 	var rc io.ReadCloser
 	var rc io.ReadCloser
 	var decoder *xml.Decoder
 	var decoder *xml.Decoder
 	var reftable []string
 	var reftable []string
+
+	// In a file with no strings it's possible that
+	// sharedStrings.xml doesn't exist.  In this case the value
+	// passed as f will be nil.
+	if f == nil {
+		return make([]string,0), nil
+	}
 	rc, error = f.Open()
 	rc, error = f.Open()
 	if error != nil {
 	if error != nil {
 		return nil, error
 		return nil, error