From 54def7eaad9ee0469ca495b3661798919239384a Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 27 Jun 2019 21:58:14 +0800 Subject: [PATCH] Add TIF, TIFF format images and more detailed error information when open the encrypted file --- excelize.go | 12 +++++++++ excelize_test.go | 9 +++++++ picture.go | 2 +- picture_test.go | 25 +++++++++++++------ test/images/excel.tif | Bin 0 -> 27052 bytes xmlApp.go | 55 ++++++++++++++++++++++++++++++++++++++++++ xmlDrawing.go | 2 +- 7 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 test/images/excel.tif create mode 100644 xmlApp.go 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 } diff --git a/excelize_test.go b/excelize_test.go index c7c3aec..c4a06a5 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -1,6 +1,7 @@ package excelize import ( + "bytes" "fmt" "image/color" _ "image/gif" @@ -185,6 +186,14 @@ func TestSaveAsWrongPath(t *testing.T) { func TestOpenReader(t *testing.T) { _, err := OpenReader(strings.NewReader("")) assert.EqualError(t, err, "zip: not a valid zip file") + _, err = OpenReader(bytes.NewReader([]byte{ + 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, + })) + assert.EqualError(t, err, "not support encrypted file currently") } func TestBrokenFile(t *testing.T) { diff --git a/picture.go b/picture.go index 7804bce..812eb5c 100644 --- a/picture.go +++ b/picture.go @@ -385,7 +385,7 @@ func (f *File) addMedia(file []byte, ext string) string { // setContentTypePartImageExtensions provides a function to set the content // type for relationship parts and the Main Document part. func (f *File) setContentTypePartImageExtensions() { - var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false} + var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false, "tiff": false} content := f.contentTypesReader() for _, v := range content.Defaults { _, ok := imageTypes[v.Extension] diff --git a/picture_test.go b/picture_test.go index 890092e..9a2edda 100644 --- a/picture_test.go +++ b/picture_test.go @@ -1,8 +1,13 @@ package excelize import ( - "fmt" + _ "image/gif" + _ "image/jpeg" _ "image/png" + + _ "golang.org/x/image/tiff" + + "fmt" "io/ioutil" "os" "path/filepath" @@ -25,37 +30,41 @@ func BenchmarkAddPictureFromBytes(b *testing.B) { } func TestAddPicture(t *testing.T) { - xlsx, err := OpenFile(filepath.Join("test", "Book1.xlsx")) + f, err := OpenFile(filepath.Join("test", "Book1.xlsx")) if !assert.NoError(t, err) { t.FailNow() } // Test add picture to worksheet with offset and location hyperlink. - err = xlsx.AddPicture("Sheet2", "I9", filepath.Join("test", "images", "excel.jpg"), + err = f.AddPicture("Sheet2", "I9", filepath.Join("test", "images", "excel.jpg"), `{"x_offset": 140, "y_offset": 120, "hyperlink": "#Sheet2!D8", "hyperlink_type": "Location"}`) if !assert.NoError(t, err) { t.FailNow() } // Test add picture to worksheet with offset, external hyperlink and positioning. - err = xlsx.AddPicture("Sheet1", "F21", filepath.Join("test", "images", "excel.jpg"), + err = f.AddPicture("Sheet1", "F21", filepath.Join("test", "images", "excel.jpg"), `{"x_offset": 10, "y_offset": 10, "hyperlink": "https://github.com/360EntSecGroup-Skylar/excelize", "hyperlink_type": "External", "positioning": "oneCell"}`) if !assert.NoError(t, err) { t.FailNow() } - file, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.jpg")) + file, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png")) if !assert.NoError(t, err) { t.FailNow() } // Test add picture to worksheet from bytes. - assert.NoError(t, xlsx.AddPictureFromBytes("Sheet1", "Q1", "", "Excel Logo", ".jpg", file)) + assert.NoError(t, f.AddPictureFromBytes("Sheet1", "Q1", "", "Excel Logo", ".png", file)) // Test add picture to worksheet from bytes with illegal cell coordinates. - assert.EqualError(t, xlsx.AddPictureFromBytes("Sheet1", "A", "", "Excel Logo", ".jpg", file), `cannot convert cell "A" to coordinates: invalid cell name "A"`) + assert.EqualError(t, f.AddPictureFromBytes("Sheet1", "A", "", "Excel Logo", ".png", file), `cannot convert cell "A" to coordinates: invalid cell name "A"`) + + assert.NoError(t, f.AddPicture("Sheet1", "Q8", filepath.Join("test", "images", "excel.gif"), "")) + assert.NoError(t, f.AddPicture("Sheet1", "Q15", filepath.Join("test", "images", "excel.jpg"), "")) + assert.NoError(t, f.AddPicture("Sheet1", "Q22", filepath.Join("test", "images", "excel.tif"), "")) // Test write file to given path. - assert.NoError(t, xlsx.SaveAs(filepath.Join("test", "TestAddPicture.xlsx"))) + assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture.xlsx"))) } func TestAddPictureErrors(t *testing.T) { diff --git a/test/images/excel.tif b/test/images/excel.tif new file mode 100644 index 0000000000000000000000000000000000000000..4ce5effc4144d7e045fd14c6f40c32185a5543ad GIT binary patch literal 27052 zcmeHwcU)7=*XK<_FQFqf2}P{*jsl@cM><$2A%r53KnPWV1PiDXMX(_PBBCNq6cs^& zq9_&w1r$*!N)ag{AR>^x2^jTx{Oz*)zPtMm!{^RDbLPyMGv7IL?xmbyX}KQY002M) zSO8c62uLvs1je8rf(^(LO$KQwNW;K87bpl@;w=6av6?0l*#PTONP_7li=8PY(bBlNRkH2ZDpZ!om0=&v60#YXIQq-N={VgG1Q| z5J-gZ0759r!~~_LqN;;hYm31K;_1wF0LakQQ_<2>(?+Rk>Zxn!si*;)4WmOb*dQDU z<%9DN#OuqB-L8{G1^VjCx@p>~*oKMN3gdRZm4nPfZoIRAddfKx#A5*H6#Ubj#9oU`t;%fJ6$_Q&x_O zic*SFS0WJol~r|hb(K}rl-1M}K?%k17(59Rt%whoTU7E>k0~x3OAHJp1rqQmx?YSA zA%dhYD@&hXaq5sVVW;i85fKT z!Qn~a;5gO4jtl*{d(7c~Ov&v2j}wD?Vr%>N!9VQ{3Hj^P;Uu$25P~I0|CsjY$Z+SF zP@J+OE}RfS#Nx~%!KM7d6@+awIJ=$+5r-iWh|UB;u)#81aG8$t`4NaA7?MF?2*w|$ObYb#+pPSH`!2}{`7tTO^ zv-02Ae;s9MVq#Au_yq>z48k4FjZv0nCR(bxTHwN!RDW0Vo7``D7;dCzi4P}X@K~Is zsR77P3JmnsQ&rW`*3k6RP*hX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W1ooj`?O(_=W&~K1cFM^MFFIxBruff&A50JgtwjWaMFvKOAQ#sgd^W)cb0nSZuMglR;X&TNF{bNrANa9y4LD&wB4nCRiXt;$AZE|xxij+FGK zjTvi?iobb{KnheTq^tHxc~NJ9uy*w=g^&4doE^fcXg2e4P87C&b*dV#@crmc1NJM2 z5ffUv54Z7TiGFzuOt=b?Z=PEqYeZ$p@3OFbX)V%wCS23^%(*7kz4BCH?_&;$c2ueW(f5z!}xQgW?-Inss9Lm|KRTTBjMjBr^U%X7>UN>%1 zuxE<1AuT2`uvfvqYg*oEf&8q{Tra?QUC!QJQEV|in~Mrr0HN+}TQ6oCu9^IrrvZaqEWU8P2mu9Pg3W)+!t*j%RoB7urNw}~t?c@u+Aj^|Dt|CjnOvg(TTLMEw zE~22>`?vy-L)XR6UTZqFD^H=9I<{}!bjjB3;`PgiT&ho*KYSZrAQFE_pqSHBuohQg zap9UX) be=X5y;GekVE&fj;`d?PUmS{3aFP8rSy$??x literal 0 HcmV?d00001 diff --git a/xmlApp.go b/xmlApp.go new file mode 100644 index 0000000..ad414fa --- /dev/null +++ b/xmlApp.go @@ -0,0 +1,55 @@ +// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of +// this source code is governed by a BSD-style license that can be found in +// the LICENSE file. +// +// Package excelize providing a set of functions that allow you to write to +// and read from XLSX files. Support reads and writes XLSX file generated by +// Microsoft Excelâ„¢ 2007 and later. Support save file without losing original +// charts of XLSX. This library needs Go version 1.8 or later. + +package excelize + +import "encoding/xml" + +type xlsxProperties struct { + XMLName xml.Name `xml:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties Properties"` + Template string + Manager string + Company string + Pages int + Words int + Characters int + PresentationFormat string + Lines int + Paragraphs int + Slides int + Notes int + TotalTime int + HiddenSlides int + MMClips int + ScaleCrop bool + HeadingPairs *xlsxVectorVariant + TitlesOfParts *xlsxVectorLpstr + LinksUpToDate bool + CharactersWithSpaces int + SharedDoc bool + HyperlinkBase string + HLinks *xlsxVectorVariant + HyperlinksChanged bool + DigSig *xlsxDigSig + Application string + AppVersion string + DocSecurity int +} + +type xlsxVectorVariant struct { + Content string `xml:",innerxml"` +} + +type xlsxVectorLpstr struct { + Content string `xml:",innerxml"` +} + +type xlsxDigSig struct { + Content string `xml:",innerxml"` +} diff --git a/xmlDrawing.go b/xmlDrawing.go index 13e164e..bb468bc 100644 --- a/xmlDrawing.go +++ b/xmlDrawing.go @@ -42,7 +42,7 @@ const ( NameSpaceDublinCoreMetadataIntiative = "http://purl.org/dc/dcmitype/" ) -var supportImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png"} +var supportImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff"} // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This // element specifies non-visual canvas properties. This allows for additional