diff options
author | xuri <xuri.me@gmail.com> | 2019-06-27 21:58:14 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-06-27 21:58:14 +0800 |
commit | 54def7eaad9ee0469ca495b3661798919239384a (patch) | |
tree | 4f99eeb2e929c9baa037f31574f7b45cd3d11b81 /excelize.go | |
parent | 9f8623047d2fc38e12c3b214475710d25ec88c55 (diff) |
Add TIF, TIFF format images and more detailed error information when open the encrypted file
Diffstat (limited to 'excelize.go')
-rw-r--r-- | excelize.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/excelize.go b/excelize.go index 6fb98c4..f636a84 100644 --- a/excelize.go +++ b/excelize.go @@ -14,6 +14,7 @@ import ( "archive/zip" "bytes" "encoding/xml" + "errors" "fmt" "io" "io/ioutil" @@ -69,6 +70,17 @@ func OpenReader(r io.Reader) (*File, error) { zr, err := zip.NewReader(bytes.NewReader(b), int64(len(b))) if err != nil { + identifier := []byte{ + // checking protect workbook by [MS-OFFCRYPTO] - v20181211 3.1 FeatureIdentifier + 0x3c, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, + 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, + 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x44, 0x00, 0x61, 0x00, + 0x74, 0x00, 0x61, 0x00, 0x53, 0x00, 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x73, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + } + if bytes.Contains(b, identifier) { + return nil, errors.New("not support encrypted file currently") + } return nil, err } |