From b7cd5cf2661564761df61abd56e2394225a9ca39 Mon Sep 17 00:00:00 2001 From: Alexander Diana Date: Wed, 1 Nov 2023 16:57:21 +0000 Subject: [PATCH] update unit test to handle mongodb time rounding --- data/store/mongo/mongo_test.go | 2 +- go.mod | 6 +- go.sum | 16 ++-- .../github.com/aws/aws-sdk-go/aws/version.go | 2 +- .../tdewolff/minify/v2/html/html.go | 29 +++--- .../tdewolff/minify/v2/html/table.go | 89 +++++++++---------- vendor/github.com/tdewolff/minify/v2/js/js.go | 7 +- .../github.com/tdewolff/parse/v2/html/lex.go | 8 +- .../github.com/tdewolff/parse/v2/js/parse.go | 38 +++++--- vendor/modules.txt | 8 +- 10 files changed, 110 insertions(+), 95 deletions(-) diff --git a/data/store/mongo/mongo_test.go b/data/store/mongo/mongo_test.go index 8764413b8..f904bcd28 100644 --- a/data/store/mongo/mongo_test.go +++ b/data/store/mongo/mongo_test.go @@ -1430,7 +1430,7 @@ var _ = Describe("Mongo", func() { Expect(userLastUpdated).ToNot(BeNil()) Expect(err).ToNot(HaveOccurred()) Expect(userLastUpdated.LastData).To(Equal(dataSetData[len(dataSetData)-1].GetTime().Truncate(time.Millisecond))) - Expect(userLastUpdated.LastUpload).To(Equal(createdTime)) + Expect(userLastUpdated.LastUpload).To(BeTemporally("~", createdTime, time.Second)) }) It("correctly does not find the LastUpload and LastData for an inactive type", func() { diff --git a/go.mod b/go.mod index c7df057c0..cab4a0f42 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.21.0 require ( github.com/IBM/sarama v1.41.3 github.com/ant0ine/go-json-rest v3.3.2+incompatible - github.com/aws/aws-sdk-go v1.46.7 + github.com/aws/aws-sdk-go v1.47.0 github.com/blang/semver v3.5.1+incompatible github.com/deckarep/golang-set/v2 v2.3.1 github.com/githubnemo/CompileDaemon v1.4.0 @@ -127,8 +127,8 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/schollz/closestmatch v2.1.0+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/tdewolff/minify/v2 v2.20.3 // indirect - github.com/tdewolff/parse/v2 v2.7.2 // indirect + github.com/tdewolff/minify/v2 v2.20.5 // indirect + github.com/tdewolff/parse/v2 v2.7.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect diff --git a/go.sum b/go.sum index d5ec12998..d9d98d616 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7D github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= -github.com/aws/aws-sdk-go v1.46.7 h1:IjvAWeiJZlbETOemOwvheN5L17CvKvKW0T1xOC6d3Sc= -github.com/aws/aws-sdk-go v1.46.7/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.47.0 h1:/JUg9V1+xh+qBn8A6ec/l15ETPaMaBqxkjz+gg63dNk= +github.com/aws/aws-sdk-go v1.47.0/go.mod h1:DlEaEbWKZmsITVbqlSVvekPARM1HzeV9PMYg15ymSDA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= @@ -352,10 +352,10 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tdewolff/minify/v2 v2.20.3 h1:8x2BICr21IoNFda5EUyNsoNcEZHL/W0ap+sfUJiGdmg= -github.com/tdewolff/minify/v2 v2.20.3/go.mod h1:AMF0J/eNujZLDbfMZvWweg5TSG/KuK+/UGKc+k1N8/w= -github.com/tdewolff/parse/v2 v2.7.2 h1:9NdxF0nk/+lPI0YADDonSlpiY15hGcVUhXRj9hnK8sM= -github.com/tdewolff/parse/v2 v2.7.2/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= +github.com/tdewolff/minify/v2 v2.20.5 h1:IbJpmpAFESnuJPdsvFBJWsDcXE5qHsmaVQrRqhOI9sI= +github.com/tdewolff/minify/v2 v2.20.5/go.mod h1:N78HtaitkDYAWXFbqhWX/LzgwylwudK0JvybGDVQ+Mw= +github.com/tdewolff/parse/v2 v2.7.3 h1:SHj/ry85FdqniccvzJTG+Gt/mi/HNa1cJcTzYZnvc5U= +github.com/tdewolff/parse/v2 v2.7.3/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= github.com/tdewolff/test v1.0.10 h1:uWiheaLgLcNFqHcdWveum7PQfMnIUTf9Kl3bFxrIoew= github.com/tdewolff/test v1.0.10/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tidepool-org/clinic/client v0.0.0-20231026151906-ad2e71e79f6f h1:WUj7V54KaBeHWfCH4TZ4Jkw1J+pWXOd39E5cD5NhsbE= @@ -469,7 +469,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= @@ -509,7 +508,6 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= @@ -517,7 +515,6 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= @@ -527,7 +524,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index a516335df..9b97972df 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.46.7" +const SDKVersion = "1.47.0" diff --git a/vendor/github.com/tdewolff/minify/v2/html/html.go b/vendor/github.com/tdewolff/minify/v2/html/html.go index 014ffe876..1a5aa9450 100644 --- a/vendor/github.com/tdewolff/minify/v2/html/html.go +++ b/vendor/github.com/tdewolff/minify/v2/html/html.go @@ -134,7 +134,6 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st w.Write(t.Data) } case html.TextToken: - // CSS and JS minifiers for inline code if t.HasTemplate { w.Write(t.Data) } else if rawTagHash != 0 { @@ -402,30 +401,30 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st attr.Hash == Action && t.Hash == Form) { continue // omit empty attribute values } - if attr.Traits&caselessAttr != 0 { - val = parse.ToLower(val) - } if rawTagHash != 0 && attr.Hash == Type { rawTagMediatype = parse.Copy(val) } - if attr.Hash == Enctype || attr.Hash == Accept || attr.Hash == Type && (t.Hash == A || t.Hash == Link || t.Hash == Embed || t.Hash == Object || t.Hash == Source || t.Hash == Script) { + if attr.Hash == Enctype || + attr.Hash == Formenctype || + attr.Hash == Accept || + attr.Hash == Type && (t.Hash == A || t.Hash == Link || t.Hash == Embed || t.Hash == Object || t.Hash == Source || t.Hash == Script) { val = minify.Mediatype(val) } // default attribute values can be omitted - if !o.KeepDefaultAttrVals && (attr.Hash == Type && (t.Hash == Script && jsMimetypes[string(val)] || - t.Hash == Style && bytes.Equal(val, cssMimeBytes) || - t.Hash == Link && bytes.Equal(val, cssMimeBytes) || - t.Hash == Input && bytes.Equal(val, textBytes) || - t.Hash == Button && bytes.Equal(val, submitBytes)) || - attr.Hash == Method && bytes.Equal(val, getBytes) || - attr.Hash == Enctype && bytes.Equal(val, formMimeBytes) || + if !o.KeepDefaultAttrVals && (attr.Hash == Type && (t.Hash == Script && jsMimetypes[string(parse.ToLower(parse.Copy(val)))] || + t.Hash == Style && parse.EqualFold(val, cssMimeBytes) || + t.Hash == Link && parse.EqualFold(val, cssMimeBytes) || + t.Hash == Input && parse.EqualFold(val, textBytes) || + t.Hash == Button && parse.EqualFold(val, submitBytes)) || + attr.Hash == Method && parse.EqualFold(val, getBytes) || + attr.Hash == Enctype && parse.EqualFold(val, formMimeBytes) || attr.Hash == Colspan && bytes.Equal(val, oneBytes) || attr.Hash == Rowspan && bytes.Equal(val, oneBytes) || - attr.Hash == Shape && bytes.Equal(val, rectBytes) || + attr.Hash == Shape && parse.EqualFold(val, rectBytes) || attr.Hash == Span && bytes.Equal(val, oneBytes) || - attr.Hash == Media && t.Hash == Style && bytes.Equal(val, allBytes)) { + attr.Hash == Media && t.Hash == Style && parse.EqualFold(val, allBytes)) { continue } @@ -448,7 +447,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st val = val[11:] } attrMinifyBuffer.Reset() - if err := m.MinifyMimetype(jsMimeBytes, attrMinifyBuffer, buffer.NewReader(val), nil); err == nil { + if err := m.MinifyMimetype(jsMimeBytes, attrMinifyBuffer, buffer.NewReader(val), inlineParams); err == nil { val = attrMinifyBuffer.Bytes() } else if err != minify.ErrNotExist { return minify.UpdateErrorPosition(err, z, attr.Offset) diff --git a/vendor/github.com/tdewolff/minify/v2/html/table.go b/vendor/github.com/tdewolff/minify/v2/html/table.go index 9188e1c5a..37cc866b2 100644 --- a/vendor/github.com/tdewolff/minify/v2/html/table.go +++ b/vendor/github.com/tdewolff/minify/v2/html/table.go @@ -13,7 +13,6 @@ const ( const ( booleanAttr traits = 1 << iota - caselessAttr urlAttr trimAttr ) @@ -163,77 +162,77 @@ var tagMap = map[Hash]traits{ } var attrMap = map[Hash]traits{ - Accept: caselessAttr | trimAttr, // list of mimetypes - Accept_Charset: caselessAttr | trimAttr, + Accept: trimAttr, // list of mimetypes + Accept_Charset: trimAttr, Accesskey: trimAttr, Action: urlAttr, - Allow: caselessAttr | trimAttr, + Allow: trimAttr, Allowfullscreen: booleanAttr, - As: caselessAttr | trimAttr, + As: trimAttr, Async: booleanAttr, - Autocapitalize: caselessAttr | trimAttr, - Autocomplete: caselessAttr | trimAttr, + Autocapitalize: trimAttr, + Autocomplete: trimAttr, Autofocus: booleanAttr, Autoplay: booleanAttr, - Blocking: caselessAttr | trimAttr, - Capture: caselessAttr | trimAttr, - Charset: caselessAttr | trimAttr, + Blocking: trimAttr, + Capture: trimAttr, + Charset: trimAttr, Checked: booleanAttr, Cite: urlAttr, Class: trimAttr, - Color: caselessAttr | trimAttr, + Color: trimAttr, Cols: trimAttr, // uint bigger than 0 Colspan: trimAttr, // uint bigger than 0 - Contenteditable: caselessAttr | trimAttr, + Contenteditable: trimAttr, Controls: booleanAttr, Coords: trimAttr, // list of floats - Crossorigin: caselessAttr | trimAttr, + Crossorigin: trimAttr, Data: urlAttr, Datetime: trimAttr, - Decoding: caselessAttr | trimAttr, + Decoding: trimAttr, Default: booleanAttr, Defer: booleanAttr, - Dir: caselessAttr | trimAttr, + Dir: trimAttr, Disabled: booleanAttr, - Draggable: caselessAttr | trimAttr, - Enctype: caselessAttr | trimAttr, // mimetype - Enterkeyhint: caselessAttr | trimAttr, - Fetchpriority: caselessAttr | trimAttr, + Draggable: trimAttr, + Enctype: trimAttr, // mimetype + Enterkeyhint: trimAttr, + Fetchpriority: trimAttr, For: trimAttr, Form: trimAttr, Formaction: urlAttr, - Formenctype: caselessAttr | trimAttr, // mimetype - Formmethod: caselessAttr | trimAttr, + Formenctype: trimAttr, // mimetype + Formmethod: trimAttr, Formnovalidate: booleanAttr, Formtarget: trimAttr, Headers: trimAttr, - Height: trimAttr, // uint - Hidden: caselessAttr | trimAttr, // TODO: boolean - High: trimAttr, // float + Height: trimAttr, // uint + Hidden: trimAttr, // TODO: boolean + High: trimAttr, // float Href: urlAttr, Hreflang: trimAttr, // BCP 47 - Http_Equiv: caselessAttr | trimAttr, - Imagesizes: caselessAttr | trimAttr, + Http_Equiv: trimAttr, + Imagesizes: trimAttr, Imagesrcset: trimAttr, Inert: booleanAttr, - Inputmode: caselessAttr | trimAttr, - Is: caselessAttr | trimAttr, + Inputmode: trimAttr, + Is: trimAttr, Ismap: booleanAttr, Itemid: urlAttr, Itemprop: trimAttr, Itemref: trimAttr, Itemscope: booleanAttr, Itemtype: trimAttr, // list of urls - Kind: caselessAttr | trimAttr, + Kind: trimAttr, Lang: trimAttr, // BCP 47 List: trimAttr, - Loading: caselessAttr | trimAttr, + Loading: trimAttr, Loop: booleanAttr, Low: trimAttr, // float Max: trimAttr, // float or varies Maxlength: trimAttr, // uint - Media: caselessAttr | trimAttr, - Method: caselessAttr | trimAttr, + Media: trimAttr, + Method: trimAttr, Min: trimAttr, // float or varies Minlength: trimAttr, // uint Multiple: booleanAttr, @@ -245,29 +244,29 @@ var attrMap = map[Hash]traits{ Pattern: trimAttr, // regex Ping: trimAttr, // list of urls Playsinline: booleanAttr, - Popover: caselessAttr | trimAttr, + Popover: trimAttr, Popovertarget: trimAttr, - Popovertargetaction: caselessAttr | trimAttr, + Popovertargetaction: trimAttr, Poster: urlAttr, - Preload: caselessAttr | trimAttr, + Preload: trimAttr, Profile: urlAttr, Readonly: booleanAttr, - Referrerpolicy: caselessAttr | trimAttr, - Rel: caselessAttr | trimAttr, + Referrerpolicy: trimAttr, + Rel: trimAttr, Required: booleanAttr, Reversed: booleanAttr, Rows: trimAttr, // uint bigger than 0 Rowspan: trimAttr, // uint - Sandbox: caselessAttr | trimAttr, - Scope: caselessAttr | trimAttr, + Sandbox: trimAttr, + Scope: trimAttr, Selected: booleanAttr, - Shadowrootmode: caselessAttr | trimAttr, + Shadowrootmode: trimAttr, Shadowrootdelegatesfocus: booleanAttr, - Shape: caselessAttr | trimAttr, + Shape: trimAttr, Size: trimAttr, // uint bigger than 0 - Sizes: caselessAttr | trimAttr, + Sizes: trimAttr, Span: trimAttr, // uint bigger than 0 - Spellcheck: caselessAttr | trimAttr, + Spellcheck: trimAttr, Src: urlAttr, Srclang: trimAttr, // BCP 47 Srcset: trimAttr, @@ -275,11 +274,11 @@ var attrMap = map[Hash]traits{ Step: trimAttr, // float or "any" Tabindex: trimAttr, // int Target: trimAttr, - Translate: caselessAttr | trimAttr, + Translate: trimAttr, Type: trimAttr, Usemap: trimAttr, Width: trimAttr, // uint - Wrap: caselessAttr | trimAttr, + Wrap: trimAttr, Xmlns: urlAttr, } diff --git a/vendor/github.com/tdewolff/minify/v2/js/js.go b/vendor/github.com/tdewolff/minify/v2/js/js.go index 0a2af90bd..eed47ba93 100644 --- a/vendor/github.com/tdewolff/minify/v2/js/js.go +++ b/vendor/github.com/tdewolff/minify/v2/js/js.go @@ -36,9 +36,12 @@ func Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) err } // Minify minifies JS data, it reads from r and writes to w. -func (o *Minifier) Minify(_ *minify.M, w io.Writer, r io.Reader, _ map[string]string) error { +func (o *Minifier) Minify(_ *minify.M, w io.Writer, r io.Reader, params map[string]string) error { z := parse.NewInput(r) - ast, err := js.Parse(z, js.Options{WhileToFor: true}) + ast, err := js.Parse(z, js.Options{ + WhileToFor: true, + Inline: params != nil && params["inline"] == "1", + }) if err != nil { return err } diff --git a/vendor/github.com/tdewolff/parse/v2/html/lex.go b/vendor/github.com/tdewolff/parse/v2/html/lex.go index 892e1569e..8fc9073d8 100644 --- a/vendor/github.com/tdewolff/parse/v2/html/lex.go +++ b/vendor/github.com/tdewolff/parse/v2/html/lex.go @@ -151,7 +151,7 @@ func (l *Lexer) Next() (TokenType, []byte) { } if l.rawTag != 0 { - if rawText := l.shiftRawText(); len(rawText) > 0 { + if rawText := l.shiftRawText(); 0 < len(rawText) { l.text = rawText l.rawTag = 0 return TextToken, rawText @@ -193,7 +193,7 @@ func (l *Lexer) Next() (TokenType, []byte) { l.moveTemplate() l.hasTmpl = true } else if c == 0 && l.r.Err() != nil { - if l.r.Pos() > 0 { + if 0 < l.r.Pos() { l.text = l.r.Shift() return TextToken, l.text } @@ -274,6 +274,10 @@ func (l *Lexer) shiftRawText() []byte { } else { l.r.Move(1) } + } else if 0 < len(l.tmplBegin) && l.at(l.tmplBegin...) { + l.r.Move(len(l.tmplBegin)) + l.moveTemplate() + l.hasTmpl = true } else if c == 0 && l.r.Err() != nil { return l.r.Shift() } else { diff --git a/vendor/github.com/tdewolff/parse/v2/js/parse.go b/vendor/github.com/tdewolff/parse/v2/js/parse.go index cd526bfc2..44c0da955 100644 --- a/vendor/github.com/tdewolff/parse/v2/js/parse.go +++ b/vendor/github.com/tdewolff/parse/v2/js/parse.go @@ -12,6 +12,7 @@ import ( type Options struct { WhileToFor bool + Inline bool } // Parser is the state for the parser. @@ -44,20 +45,33 @@ func Parse(r *parse.Input, o Options) (*AST, error) { await: true, } - // catch shebang in first line - var shebang []byte - if r.Peek(0) == '#' && r.Peek(1) == '!' { - r.Move(2) - p.l.consumeSingleLineComment() // consume till end-of-line - shebang = r.Shift() - } + if o.Inline { + p.next() + p.retrn = true + p.allowDirectivePrologue = true + p.enterScope(&ast.BlockStmt.Scope, true) + for { + if p.tt == ErrorToken { + break + } + ast.BlockStmt.List = append(ast.BlockStmt.List, p.parseStmt(true)) + } + } else { + // catch shebang in first line + var shebang []byte + if r.Peek(0) == '#' && r.Peek(1) == '!' { + r.Move(2) + p.l.consumeSingleLineComment() // consume till end-of-line + shebang = r.Shift() + } - // parse JS module - p.next() - ast.BlockStmt = p.parseModule() + // parse JS module + p.next() + ast.BlockStmt = p.parseModule() - if 0 < len(shebang) { - ast.BlockStmt.List = append([]IStmt{&Comment{shebang}}, ast.BlockStmt.List...) + if 0 < len(shebang) { + ast.BlockStmt.List = append([]IStmt{&Comment{shebang}}, ast.BlockStmt.List...) + } } if p.err == nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index fd48a490b..b50bad3d9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -33,8 +33,8 @@ github.com/apapsch/go-jsonmerge/v2 # github.com/avast/retry-go v3.0.0+incompatible ## explicit github.com/avast/retry-go -# github.com/aws/aws-sdk-go v1.46.7 -## explicit; go 1.11 +# github.com/aws/aws-sdk-go v1.47.0 +## explicit; go 1.19 github.com/aws/aws-sdk-go/aws github.com/aws/aws-sdk-go/aws/arn github.com/aws/aws-sdk-go/aws/auth/bearer @@ -569,7 +569,7 @@ github.com/schollz/closestmatch # github.com/sirupsen/logrus v1.9.3 ## explicit; go 1.13 github.com/sirupsen/logrus -# github.com/tdewolff/minify/v2 v2.20.3 +# github.com/tdewolff/minify/v2 v2.20.5 ## explicit; go 1.18 github.com/tdewolff/minify/v2 github.com/tdewolff/minify/v2/css @@ -578,7 +578,7 @@ github.com/tdewolff/minify/v2/js github.com/tdewolff/minify/v2/json github.com/tdewolff/minify/v2/svg github.com/tdewolff/minify/v2/xml -# github.com/tdewolff/parse/v2 v2.7.2 +# github.com/tdewolff/parse/v2 v2.7.3 ## explicit; go 1.13 github.com/tdewolff/parse/v2 github.com/tdewolff/parse/v2/buffer