From b9cceb70ae56032d3db7a4117f52c25715ce5dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 29 Jul 2021 11:57:51 +0200 Subject: [PATCH] Making doc extraction more reliable (#17842) * Making doc extraction more reliable * fix error message * Adding test doc file * Removing test that not works on CI because the lack of a binary Co-authored-by: Mattermod --- go.mod | 2 +- go.sum | 2 ++ services/docextractor/docextractor_test.go | 2 +- services/docextractor/documents.go | 9 ++++++++- tests/sample-doc.doc | Bin 0 -> 9216 bytes vendor/code.sajari.com/docconv/.travis.yml | 10 ---------- vendor/code.sajari.com/docconv/README.md | 8 +++++--- vendor/code.sajari.com/docconv/go.mod | 1 + vendor/code.sajari.com/docconv/go.sum | 9 --------- vendor/code.sajari.com/docconv/local.go | 2 +- vendor/code.sajari.com/docconv/pages.go | 15 ++++++++++++--- vendor/code.sajari.com/docconv/rtf.go | 2 +- vendor/code.sajari.com/docconv/tidy.go | 2 +- vendor/modules.txt | 2 +- 14 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 tests/sample-doc.doc delete mode 100644 vendor/code.sajari.com/docconv/.travis.yml diff --git a/go.mod b/go.mod index 2d85fb41a8..04111ac781 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/mattermost/mattermost-server/v6 go 1.15 require ( - code.sajari.com/docconv v1.1.1-0.20200701232649-d9ea05fbd50a + code.sajari.com/docconv v1.1.1-0.20210427001343-7b3472bc323a github.com/HdrHistogram/hdrhistogram-go v0.9.0 // indirect github.com/Masterminds/semver/v3 v3.1.1 github.com/Masterminds/squirrel v1.5.0 diff --git a/go.sum b/go.sum index 5f44b0ffc3..9e7ed86417 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= code.sajari.com/docconv v1.1.1-0.20200701232649-d9ea05fbd50a h1:e0dRHyAfGcext3/lnwfsl81PKJRNgLyA843n72mPCes= code.sajari.com/docconv v1.1.1-0.20200701232649-d9ea05fbd50a/go.mod h1:DooS873W9YwUjTwEYGpg55aDlvnx1VcEdr7IJ9rEW8g= +code.sajari.com/docconv v1.1.1-0.20210427001343-7b3472bc323a h1:AEvqb7V5SSC89lAp9UQd7ytVVLm6f4AQbtzr9lk0bFg= +code.sajari.com/docconv v1.1.1-0.20210427001343-7b3472bc323a/go.mod h1:KPNt2zuWplps1W0TpOb6ltHj4Xu+j6h7a+YkqGHrxQE= contrib.go.opencensus.io/exporter/ocagent v0.4.9/go.mod h1:ueLzZcP7LPhPulEBukGn4aLh7Mx9YJwpVJ9nL2FYltw= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/services/docextractor/docextractor_test.go b/services/docextractor/docextractor_test.go index dd655872aa..26bd1e1266 100644 --- a/services/docextractor/docextractor_test.go +++ b/services/docextractor/docextractor_test.go @@ -150,7 +150,7 @@ func TestExtract(t *testing.T) { require.Equal(t, "", text) }) - t.Run("Wrong extension", func(t *testing.T) { + t.Run("Wrong docx extension", func(t *testing.T) { data, err := testutils.ReadTestFile("sample-doc.pdf") require.NoError(t, err) text, err := Extract("sample-doc.docx", bytes.NewReader(data), ExtractSettings{}) diff --git a/services/docextractor/documents.go b/services/docextractor/documents.go index f67c17fd50..da44e30fcb 100644 --- a/services/docextractor/documents.go +++ b/services/docextractor/documents.go @@ -31,7 +31,14 @@ func (de *documentExtractor) Match(filename string) bool { return ok } -func (de *documentExtractor) Extract(filename string, r io.ReadSeeker) (string, error) { +func (de *documentExtractor) Extract(filename string, r io.ReadSeeker) (out string, outErr error) { + defer func() { + if r := recover(); r != nil { + out = "" + outErr = errors.New("error extracting document text") + } + }() + extension := strings.TrimPrefix(path.Ext(filename), ".") converter, ok := doconvConverterByExtensions[extension] if !ok { diff --git a/tests/sample-doc.doc b/tests/sample-doc.doc new file mode 100644 index 0000000000000000000000000000000000000000..10e53e66863cd761d80ebc84e900774aed7ae550 GIT binary patch literal 9216 zcmeI1TWnNC7{|Y}-QJK(*dZgAbY*6A%-PL47sR#F!WpBM)N2TYWU~0gOKIK+E_7LGcUuVo+1dPdu4lfP zZ@!r`Gw1xz3&%eCV(D*|=C)X#jZYL?K}xzqctH>^F$)n^+W5r8M377{=k6d4T=m{X3|;xu&LRV812#jat-p*dYF}y~e0!@5->4 z)GD)iGIhPkrhKL{Ir)g+*{Ll)++H0{6jESO&}C zevqsc_)$Mxj=u_G@F1*)HLw;Qf_1PSHo!)xfJ&%>YN&x)co;UpW_SeZpdKEDEwB}~ z!DH|^G(aOX!FFhd9nby2*qt^02+8o&1b!^6puWbbJ7U~)LIu{rtj(Se@9QTLtD-leqW z z7mdR6ZTS`_|Ap52@HB0cC5^9eEab?d3bCgiT9L4RR@xUynMa#TPhUd*F)N5U%$JU~ z0)!VJd^rLO%@ed7%Wf)BJ+km(?5xL*xodV4eM`72b_rt;Ni1?4YE+NjrexGAOB^TS zLm<}@z9EjTxCHkp#kd%4M>{8mM_RXbz5mzaji=3eU z&lNeV-5%E9Ywxg&=Mrw~6f1R~@+6V%&QbKG?SpG?+FCpS?~HWt{0ng^_#CuLT(tFx2di0SqF zrq_=oN9$z{5S&;gh&2+*JM5_^6 q!7qHK{%G>Phcc6H~w`dWSXcdxpQy zRo9sx-#Ys-sG*+zwEflV#c|_dJK+xd^{HM-v$OdqO>X)%!7Y;en_2^rs;Tp4o0B%f zqgmE7!cg%$Z=)5)rlJNUgvj_aJ_Dv07E#GPD<%Jc%HNf%8!pP!Nzq)UR<0md} zRaklH?vFE$(;h9x z;Jz!=5QPIhD4g!zbQ3=D+Z_1mrBdT6vnVwoL-=dTOUpm_eo*{x;>}X`e{{c4&upBw zB;6_U$EZiU@|^pBYCv`(JG|8{WEXF>$eg^K267s>tu%1J`Z$#6aOM5S35^gQVApYk z<3N;MNYW15QTGt08^$Q~xksBQ={jkS64RMjwTzIW9@cY)d%;~2WdwpLj~Czt4*AzN|od}Z|9*tV7D2E*mB z>f~TJ1~ueYpG;WQkW^PoY;BFruTo^H^REstp$k7<_@H80$*K1^|8BVQc{6GGX=%@r zrh96~rvzWm>a06eI@vkrYv5*n|I-+xe?z#DqVtrf4@5YJOGdr%hxnq>Z7+F=Gx(1% z+8S>Tz22R2md^%~9OP=BGFvwX>H2n}KFQCf9H;Tef!l7elH{9eK85HpS`j-`d^ED-QTOaY~||?>NCHxgRZOu-`=j@ uCHmPJy`{70|4M2N?w#`gC3$B0sGEiSXOOS&FgMG&1MmN3Q)lY;-+utHckWUE literal 0 HcmV?d00001 diff --git a/vendor/code.sajari.com/docconv/.travis.yml b/vendor/code.sajari.com/docconv/.travis.yml deleted file mode 100644 index 19271c3830..0000000000 --- a/vendor/code.sajari.com/docconv/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -sudo: false -language: go -go: -- "1.13" -- "1.14" -- tip -go_import_path: code.sajari.com/docconv -notifications: - email: - - infra@sajari.com diff --git a/vendor/code.sajari.com/docconv/README.md b/vendor/code.sajari.com/docconv/README.md index 9593432582..56a4683aeb 100644 --- a/vendor/code.sajari.com/docconv/README.md +++ b/vendor/code.sajari.com/docconv/README.md @@ -1,11 +1,13 @@ # docconv -[![GoDoc](https://godoc.org/code.sajari.com/docconv?status.svg)](https://godoc.org/code.sajari.com/docconv) -[![Build Status](https://travis-ci.org/sajari/docconv.svg?branch=master)](https://travis-ci.org/sajari/docconv) +[![Go reference](https://pkg.go.dev/badge/code.sajari.com/docconv.svg)](https://pkg.go.dev/code.sajari.com/docconv) +[![Build status](https://github.com/sajari/docconv/workflows/Go/badge.svg?branch=master)](https://github.com/sajari/docconv/actions) +[![Report card](https://goreportcard.com/badge/code.sajari.com/docconv)](https://goreportcard.com/report/code.sajari.com/docconv) +[![Sourcegraph](https://sourcegraph.com/github.com/sajari/docconv/-/badge.svg)](https://sourcegraph.com/github.com/sajari/docconv) A Go wrapper library to convert PDF, DOC, DOCX, XML, HTML, RTF, ODT, Pages documents and images (see optional dependencies below) to plain text. -> **Note for returning users:** the Go import path for this package been moved to `code.sajari.com/docconv`. +> **Note for returning users:** the Go import path for this package changed to `code.sajari.com/docconv`. ## Installation diff --git a/vendor/code.sajari.com/docconv/go.mod b/vendor/code.sajari.com/docconv/go.mod index 1ff6dcd7ea..5de3eebe63 100644 --- a/vendor/code.sajari.com/docconv/go.mod +++ b/vendor/code.sajari.com/docconv/go.mod @@ -10,6 +10,7 @@ require ( github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect github.com/go-resty/resty/v2 v2.3.0 // indirect github.com/golang/protobuf v1.4.2 + github.com/google/go-cmp v0.4.0 github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 // indirect github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect diff --git a/vendor/code.sajari.com/docconv/go.sum b/vendor/code.sajari.com/docconv/go.sum index 3b1d3e69ca..f93393fe50 100644 --- a/vendor/code.sajari.com/docconv/go.sum +++ b/vendor/code.sajari.com/docconv/go.sum @@ -1,17 +1,14 @@ github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198 h1:8P+AjBhGByCuCX2zTkAf6UY+dj0JczX+t6cSdCSyvfw= github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198/go.mod h1:0SURuH1rsE8aVWvutuMZghRNrNrYEUzibzJfhEYR8L0= -github.com/PuerkitoBio/goquery v1.4.1 h1:smcIRGdYm/w7JSbcdeLHEMzxmsBQvl8lhf0dSw2nzMI= github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA= github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1 h1:d0Ct1dZwgwMO0Llf81Eu+Lyj6kwqXdqHP/WsSkEria0= github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1/go.mod h1:f3HCSN1fBWjcpGtXyM119MJgeQl838v6so/PQOqvE1w= -github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o= github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE= github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY= -github.com/araddon/dateparse v0.0.0-20180729174819-cfd92a431d0e h1:s05JG2GwtJMHaPcXDpo4V35TFgyYZzNsmBlSkHPEbeg= github.com/araddon/dateparse v0.0.0-20180729174819-cfd92a431d0e/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI= github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 h1:TEBmxO80TM04L8IuMWk77SGL1HomBmKTdzdJLLWznxI= github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI= @@ -21,7 +18,6 @@ github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA= github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573 h1:u8AQ9bPa9oC+8/A/jlWouakhIvkFfuxgIIRjiy8av7I= github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573/go.mod h1:eBvb3i++NHDH4Ugo9qCvMw8t0mTSctaEa5blJbWcNxs= -github.com/go-resty/resty/v2 v2.0.0 h1:9Nq/U+V4xsoDnDa/iTrABDWUCuk3Ne92XFHPe6dKWUc= github.com/go-resty/resty/v2 v2.0.0/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= @@ -36,18 +32,15 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 h1:xqgexXAGQgY3HAjNPSaCqn5Aahbo5TKsmhp8VRfr1iQ= github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaEQ0TRq1iBvemFRf+8AEWEmBESSiWB3Vsc= github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 h1:W7p+m/AECTL3s/YR5RpQ4hz5SjNeKzZBl1q36ws12s0= github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5/go.mod h1:QMe2wuKJ0o7zIVE8AqiT8rd8epmm6WDIZ2wyuBqYPzM= -github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84 h1:fiKJgB4JDUd43CApkmCeTSQlWjtTtABrU2qsgbuP0BI= github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= @@ -57,7 +50,6 @@ github.com/otiai10/gosseract/v2 v2.2.4 h1:h/PV+oJqke8q2Ccw9bjpMBWfd7N2vtGDCUcihZ github.com/otiai10/gosseract/v2 v2.2.4/go.mod h1:ahOp/kHojnOMGv1RaUnR0jwY5JVa6BYKhYAS8nbMLSo= github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -78,7 +70,6 @@ golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYc golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/vendor/code.sajari.com/docconv/local.go b/vendor/code.sajari.com/docconv/local.go index 40bcc9916e..739115e0b9 100644 --- a/vendor/code.sajari.com/docconv/local.go +++ b/vendor/code.sajari.com/docconv/local.go @@ -25,7 +25,7 @@ func NewLocalFile(r io.Reader) (*LocalFile, error) { }, nil } - f, err := ioutil.TempFile(os.TempDir(), "/docconv") + f, err := ioutil.TempFile(os.TempDir(), "docconv") if err != nil { return nil, fmt.Errorf("error creating temporary file: %v", err) } diff --git a/vendor/code.sajari.com/docconv/pages.go b/vendor/code.sajari.com/docconv/pages.go index c2883148a2..f40dde9ce8 100644 --- a/vendor/code.sajari.com/docconv/pages.go +++ b/vendor/code.sajari.com/docconv/pages.go @@ -12,7 +12,7 @@ import ( "github.com/golang/protobuf/proto" - "code.sajari.com/docconv/iWork" + TSP "code.sajari.com/docconv/iWork" "code.sajari.com/docconv/snappy" ) @@ -48,8 +48,17 @@ func ConvertPages(r io.Reader) (string, map[string]string, error) { rc, _ := f.Open() defer rc.Close() bReader := bufio.NewReader(snappy.NewReader(io.MultiReader(strings.NewReader("\xff\x06\x00\x00sNaPpY"), rc))) - archiveLength, err := binary.ReadVarint(bReader) - archiveInfoData, err := ioutil.ReadAll(io.LimitReader(bReader, archiveLength)) + + // Ignore error. + // NOTE: This error was unchecked. Need to revisit this to see if it + // should be acted on. + archiveLength, _ := binary.ReadVarint(bReader) + + // Ignore error. + // NOTE: This error was unchecked. Need to revisit this to see if it + // should be acted on. + archiveInfoData, _ := ioutil.ReadAll(io.LimitReader(bReader, archiveLength)) + archiveInfo := &TSP.ArchiveInfo{} err = proto.Unmarshal(archiveInfoData, archiveInfo) fmt.Println("archiveInfo:", archiveInfo, err) diff --git a/vendor/code.sajari.com/docconv/rtf.go b/vendor/code.sajari.com/docconv/rtf.go index 98e1363fcd..6fea0e3e1a 100644 --- a/vendor/code.sajari.com/docconv/rtf.go +++ b/vendor/code.sajari.com/docconv/rtf.go @@ -28,7 +28,7 @@ func ConvertRTF(r io.Reader) (string, map[string]string, error) { if parts := strings.SplitN(line, ":", 2); len(parts) > 1 { meta[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) } - if len(line) > 4 && line[:4] != "### " { + if !strings.HasPrefix(line, "### ") { output += line + "\n" } } diff --git a/vendor/code.sajari.com/docconv/tidy.go b/vendor/code.sajari.com/docconv/tidy.go index b120ee5625..c4475dc4a3 100644 --- a/vendor/code.sajari.com/docconv/tidy.go +++ b/vendor/code.sajari.com/docconv/tidy.go @@ -11,7 +11,7 @@ import ( // Errors & warnings are deliberately suppressed as underlying tools // throw warnings very easily. func Tidy(r io.Reader, xmlIn bool) ([]byte, error) { - f, err := ioutil.TempFile(os.TempDir(), "/docconv") + f, err := ioutil.TempFile(os.TempDir(), "docconv") if err != nil { return nil, err } diff --git a/vendor/modules.txt b/vendor/modules.txt index cafd9fb3be..b5617c2ef1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# code.sajari.com/docconv v1.1.1-0.20200701232649-d9ea05fbd50a +# code.sajari.com/docconv v1.1.1-0.20210427001343-7b3472bc323a ## explicit code.sajari.com/docconv code.sajari.com/docconv/iWork