From cd796877454ce9488e0ea6b9d533f5ab0807f6de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 04:35:38 +0000 Subject: [PATCH] Bump the go-modules-updates group with 7 updates Bumps the go-modules-updates group with 7 updates: | Package | From | To | | --- | --- | --- | | [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) | `1.12.0` | `1.13.0` | | [github.com/go-pkgz/lgr](https://github.com/go-pkgz/lgr) | `0.12.3` | `0.12.4` | | [github.com/go-pkgz/rest](https://github.com/go-pkgz/rest) | `1.23.1` | `1.24.0` | | [github.com/go-pkgz/routegroup](https://github.com/go-pkgz/routegroup) | `1.6.0` | `1.6.1` | | [github.com/stretchr/testify](https://github.com/stretchr/testify) | `1.11.1` | `1.12.0` | | [go.mongodb.org/mongo-driver/v2](https://github.com/mongodb/mongo-go-driver) | `2.8.0` | `2.8.2` | | [golang.org/x/net](https://github.com/golang/net) | `0.57.0` | `0.58.0` | Updates `github.com/PuerkitoBio/goquery` from 1.12.0 to 1.13.0 - [Release notes](https://github.com/PuerkitoBio/goquery/releases) - [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.12.0...v1.13.0) Updates `github.com/go-pkgz/lgr` from 0.12.3 to 0.12.4 - [Release notes](https://github.com/go-pkgz/lgr/releases) - [Commits](https://github.com/go-pkgz/lgr/compare/v0.12.3...v0.12.4) Updates `github.com/go-pkgz/rest` from 1.23.1 to 1.24.0 - [Release notes](https://github.com/go-pkgz/rest/releases) - [Commits](https://github.com/go-pkgz/rest/compare/v1.23.1...v1.24.0) Updates `github.com/go-pkgz/routegroup` from 1.6.0 to 1.6.1 - [Release notes](https://github.com/go-pkgz/routegroup/releases) - [Commits](https://github.com/go-pkgz/routegroup/compare/v1.6.0...v1.6.1) Updates `github.com/stretchr/testify` from 1.11.1 to 1.12.0 - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.11.1...v1.12.0) Updates `go.mongodb.org/mongo-driver/v2` from 2.8.0 to 2.8.2 - [Release notes](https://github.com/mongodb/mongo-go-driver/releases) - [Commits](https://github.com/mongodb/mongo-go-driver/compare/v2.8.0...v2.8.2) Updates `golang.org/x/net` from 0.57.0 to 0.58.0 - [Commits](https://github.com/golang/net/compare/v0.57.0...v0.58.0) --- updated-dependencies: - dependency-name: github.com/PuerkitoBio/goquery dependency-version: 1.13.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: github.com/go-pkgz/lgr dependency-version: 0.12.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: go-modules-updates - dependency-name: github.com/go-pkgz/rest dependency-version: 1.24.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: github.com/go-pkgz/routegroup dependency-version: 1.6.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: go-modules-updates - dependency-name: github.com/stretchr/testify dependency-version: 1.12.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: go.mongodb.org/mongo-driver/v2 dependency-version: 2.8.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: go-modules-updates - dependency-name: golang.org/x/net dependency-version: 0.58.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates ... Signed-off-by: dependabot[bot] --- go.mod | 20 +- go.sum | 37 ++- .../github.com/PuerkitoBio/goquery/README.md | 3 + .../github.com/PuerkitoBio/goquery/array.go | 8 +- .../github.com/PuerkitoBio/goquery/filter.go | 77 +++-- .../PuerkitoBio/goquery/manipulation.go | 77 ++--- .../PuerkitoBio/goquery/property.go | 89 +++--- .../github.com/PuerkitoBio/goquery/query.go | 27 +- .../PuerkitoBio/goquery/traversal.go | 62 ++-- vendor/github.com/PuerkitoBio/goquery/type.go | 23 +- .../PuerkitoBio/goquery/utilities.go | 68 ++++- vendor/github.com/go-pkgz/lgr/logger.go | 6 + vendor/github.com/go-pkgz/rest/README.md | 89 +++++- vendor/github.com/go-pkgz/rest/benchmarks.go | 4 +- vendor/github.com/go-pkgz/rest/blackwords.go | 22 +- .../github.com/go-pkgz/rest/cache_control.go | 60 ++-- vendor/github.com/go-pkgz/rest/cors.go | 34 ++- vendor/github.com/go-pkgz/rest/file_server.go | 14 +- vendor/github.com/go-pkgz/rest/gzip.go | 286 +++++++++++++++--- vendor/github.com/go-pkgz/rest/metrics.go | 23 +- vendor/github.com/go-pkgz/rest/middleware.go | 9 +- vendor/github.com/go-pkgz/rest/onlyfrom.go | 15 +- vendor/github.com/go-pkgz/rest/rest.go | 13 +- .../go-pkgz/routegroup/.golangci.yml | 4 + .../github.com/go-pkgz/routegroup/README.md | 12 +- vendor/github.com/go-pkgz/routegroup/group.go | 27 +- .../testify/assert/assertion_format.go | 28 +- .../testify/assert/assertion_forward.go | 52 +++- .../testify/assert/assertion_order.go | 14 +- .../stretchr/testify/assert/assertions.go | 145 +++++---- .../github.com/stretchr/testify/assert/doc.go | 4 +- .../testify/internal/difflib}/LICENSE | 2 +- .../testify/internal}/difflib/difflib.go | 206 +------------ .../testify/internal/spew}/LICENSE | 0 .../stretchr/testify/internal/spew/README.md | 12 + .../testify/internal}/spew/bypass.go | 1 + .../testify/internal}/spew/bypasssafe.go | 1 + .../testify/internal}/spew/common.go | 0 .../testify/internal}/spew/config.go | 30 +- .../testify/internal}/spew/doc.go | 146 ++++----- .../testify/internal}/spew/dump.go | 18 +- .../testify/internal}/spew/format.go | 0 .../testify/internal}/spew/spew.go | 0 .../stretchr/testify/require/doc.go | 6 +- .../stretchr/testify/require/require.go | 102 +++---- .../stretchr/testify/require/require.go.tmpl | 2 +- .../testify/require/require_forward.go | 100 +++--- .../testify/require/require_forward.go.tmpl | 2 +- .../stretchr/testify/require/requirements.go | 8 +- .../mongo-driver/v2/mongo/bulk_write.go | 5 +- .../mongo-driver/v2/mongo/client.go | 50 ++- .../mongo-driver/v2/version/version.go | 2 +- .../v2/x/mongo/driver/operation.go | 10 +- .../x/crypto/internal/poly1305/mac_noasm.go | 2 +- .../x/crypto/internal/poly1305/sum_asm.go | 2 +- .../x/crypto/internal/poly1305/sum_riscv64.s | 158 ++++++++++ vendor/golang.org/x/crypto/ocsp/ocsp.go | 17 +- vendor/golang.org/x/crypto/ssh/certs.go | 15 +- vendor/golang.org/x/crypto/ssh/channel.go | 69 +++-- vendor/golang.org/x/crypto/ssh/client_auth.go | 2 +- vendor/golang.org/x/crypto/ssh/common.go | 8 +- vendor/golang.org/x/crypto/ssh/connection.go | 2 +- vendor/golang.org/x/crypto/ssh/handshake.go | 2 +- vendor/golang.org/x/crypto/ssh/keys.go | 17 +- vendor/golang.org/x/crypto/ssh/messages.go | 11 +- vendor/golang.org/x/crypto/ssh/mux.go | 13 +- vendor/golang.org/x/crypto/ssh/server.go | 79 +++-- vendor/golang.org/x/crypto/ssh/ssh_gss.go | 16 +- vendor/golang.org/x/crypto/ssh/streamlocal.go | 2 + vendor/golang.org/x/crypto/ssh/tcpip.go | 2 + vendor/modules.txt | 26 +- 71 files changed, 1591 insertions(+), 907 deletions(-) rename vendor/github.com/{pmezard/go-difflib => stretchr/testify/internal/difflib}/LICENSE (95%) rename vendor/github.com/{pmezard/go-difflib => stretchr/testify/internal}/difflib/difflib.go (77%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal/spew}/LICENSE (100%) create mode 100644 vendor/github.com/stretchr/testify/internal/spew/README.md rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/bypass.go (98%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/bypasssafe.go (96%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/common.go (100%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/config.go (95%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/doc.go (65%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/dump.go (96%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/format.go (100%) rename vendor/github.com/{davecgh/go-spew => stretchr/testify/internal}/spew/spew.go (100%) create mode 100644 vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s diff --git a/go.mod b/go.mod index ceac257c..aabde8ae 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/ukeeper/ukeeper-readability go 1.25.0 require ( - github.com/PuerkitoBio/goquery v1.12.0 - github.com/go-pkgz/lgr v0.12.3 - github.com/go-pkgz/rest v1.23.1 - github.com/go-pkgz/routegroup v1.6.0 + github.com/PuerkitoBio/goquery v1.13.0 + github.com/go-pkgz/lgr v0.12.4 + github.com/go-pkgz/rest v1.24.0 + github.com/go-pkgz/routegroup v1.6.1 github.com/go-pkgz/testutils v0.6.0 github.com/jessevdk/go-flags v1.6.1 github.com/kennygrant/sanitize v1.2.4 github.com/mauidude/go-readability v0.0.0-20220221173116-a9b3620098b7 - github.com/stretchr/testify v1.11.1 - go.mongodb.org/mongo-driver/v2 v2.8.0 - golang.org/x/net v0.57.0 + github.com/stretchr/testify v1.12.0 + go.mongodb.org/mongo-driver/v2 v2.8.2 + golang.org/x/net v0.58.0 ) require ( @@ -46,7 +46,6 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/cpuguy83/dockercfg v0.3.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/go-connections v0.7.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -77,7 +76,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/pkg/sftp v1.13.10 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/shirou/gopsutil/v4 v4.26.3 // indirect github.com/sirupsen/logrus v1.9.4 // indirect @@ -95,9 +93,9 @@ require ( go.opentelemetry.io/otel v1.43.0 // indirect go.opentelemetry.io/otel/metric v1.43.0 // indirect go.opentelemetry.io/otel/trace v1.43.0 // indirect - golang.org/x/crypto v0.54.0 // indirect + golang.org/x/crypto v0.55.0 // indirect golang.org/x/sync v0.22.0 // indirect golang.org/x/sys v0.47.0 // indirect - golang.org/x/text v0.40.0 // indirect + golang.org/x/text v0.41.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c59e74f0..cf4f09c3 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/goquery v1.6.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= -github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo= -github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ= +github.com/PuerkitoBio/goquery v1.13.0 h1:mqHbjD7Jmnul4DTR24LKTjo1uUmHUh072kteGV+xpFM= +github.com/PuerkitoBio/goquery v1.13.0/go.mod h1:Hip5mdBL8K2wEGKJdr27sRaNwIdDajmCwB/ExUPwW+g= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= @@ -130,12 +130,12 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/go-pkgz/lgr v0.12.3 h1:QDug7kRkEsuQtruT9fNF5PVT2kZUqCDPc4GmsgS3fP8= -github.com/go-pkgz/lgr v0.12.3/go.mod h1:lpCDgVvCIxBHZp8+sGCj9MPctIzKZyZ3QdE19ddqd54= -github.com/go-pkgz/rest v1.23.1 h1:Vp+znk3wC7NcISKdlcMiBSnDb1R0akx3V7sztBzvAeQ= -github.com/go-pkgz/rest v1.23.1/go.mod h1:+AHzjHazq7Z3Tk/kRWOhbbAz/YZlUV40feC1Hf4NtbE= -github.com/go-pkgz/routegroup v1.6.0 h1:44XHZgF6JIIldRlv+zjg6SygULASmjifnfIQjwCT0e4= -github.com/go-pkgz/routegroup v1.6.0/go.mod h1:Pmu04fhgWhRtBMIJ8HXppnnzOPjnL/IEPBIdO2zmeqg= +github.com/go-pkgz/lgr v0.12.4 h1:lDeQ4BR28ldXrKau6BOjq7A8nHzcXz+MF4xUfV4l1Ok= +github.com/go-pkgz/lgr v0.12.4/go.mod h1:Lw6DkNRnCPyX07mqkiUK/p+eA1opq4GKkWfWia64RA8= +github.com/go-pkgz/rest v1.24.0 h1:GAUCgx7U8xCOC2OynLjhCRMhtnMQH4d1mTdKpQyX2yI= +github.com/go-pkgz/rest v1.24.0/go.mod h1:dl3EWiuFB4hRTo2Sknj6UrQGFRAYvANK6/NyW8qQPxc= +github.com/go-pkgz/routegroup v1.6.1 h1:6I/0LabazpZsHAI+jYPeyH/KU2cvZF0bFylUScMNi+Q= +github.com/go-pkgz/routegroup v1.6.1/go.mod h1:Pmu04fhgWhRtBMIJ8HXppnnzOPjnL/IEPBIdO2zmeqg= github.com/go-pkgz/testutils v0.6.0 h1:+hHdikZAZm7EISWrbJ0Od42eQIAUSwoFFsTBtq3ZRKI= github.com/go-pkgz/testutils v0.6.0/go.mod h1:dtjP1TUE4EOU4Vci9wrXTdfwOo5ZKilY13pcqMrqUWA= github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= @@ -278,7 +278,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.10 h1:+5FbKNTe5Z9aspU88DPIKJ9z2KZoaGCu6Sr6kKR/5mU= github.com/pkg/sftp v1.13.10/go.mod h1:bJ1a7uDhrX/4OII+agvy28lzRvQrmIQuaHrcI1HbeGA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= @@ -322,8 +321,8 @@ github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.0 h1:K6Mr6jO9JICuend/5xzTM03ydSV3vdNRYAdPSukj8uI= +github.com/stretchr/testify v1.12.0/go.mod h1:bOYBZb5qJ00vPzWfIqBUZPaxK8jWiXc6d3ErP4Ca9Gw= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/testcontainers/testcontainers-go v0.42.0 h1:He3IhTzTZOygSXLJPMX7n44XtK+qhjat1nI9cneBbUY= github.com/testcontainers/testcontainers-go v0.42.0/go.mod h1:vZjdY1YmUA1qEForxOIOazfsrdyORJAbhi0bp8plN30= @@ -347,8 +346,8 @@ github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU= go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ= -go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= -go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= +go.mongodb.org/mongo-driver/v2 v2.8.2 h1:b6o2m7zL8g2URuO8urBedAylxojybKXNZTxgkOcl+2w= +go.mongodb.org/mongo-driver/v2 v2.8.2/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= @@ -375,8 +374,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -415,8 +414,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -462,8 +461,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/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.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/PuerkitoBio/goquery/README.md b/vendor/github.com/PuerkitoBio/goquery/README.md index 395314a0..446ba991 100644 --- a/vendor/github.com/PuerkitoBio/goquery/README.md +++ b/vendor/github.com/PuerkitoBio/goquery/README.md @@ -48,6 +48,7 @@ Ongoing goquery development is tested on the latest 2 versions of Go. **Note that goquery's API is now stable, and will not break.** +* **2026-08-27 (v1.13.0)** : Performance improvements (thanks [@jvoisin][jvs]), add top-level `Text` function with options similar to BeautifulSoup's `get_text` (thanks [@ChrisJr404][chrisjr]), update `go.mod` dependencies, add go1.27 to the test matrix. * **2026-03-15 (v1.12.0)** : Update `go.mod` dependencies, add go1.26 to the test matrix, **goquery now requires Go version 1.25+**. * **2025-11-16 (v1.11.0)** : Update `go.mod` dependencies, add go1.25 to the test matrix, **goquery now requires Go version 1.24+**. * **2025-04-11 (v1.10.3)** : Update `go.mod` dependencies, small optimization (thanks [@myxzlpltk](https://github.com/myxzlpltk)). @@ -216,3 +217,5 @@ The [BSD 3-Clause license][bsd], the same as the [Go language][golic]. Cascadia' [goq]: https://github.com/andrewstuart/goq [thiemok]: https://github.com/thiemok [djw]: https://github.com/davidjwilkins +[jvs]: https://github.com/jvoisin +[chrisjr]: https://github.com/ChrisJr404 diff --git a/vendor/github.com/PuerkitoBio/goquery/array.go b/vendor/github.com/PuerkitoBio/goquery/array.go index 1b1f6cbe..f75be617 100644 --- a/vendor/github.com/PuerkitoBio/goquery/array.go +++ b/vendor/github.com/PuerkitoBio/goquery/array.go @@ -81,7 +81,13 @@ func (s *Selection) Get(index int) *html.Node { // relative to its sibling elements. func (s *Selection) Index() int { if len(s.Nodes) > 0 { - return newSingleSelection(s.Nodes[0], s.document).PrevAll().Length() + i := 0 + for n := s.Nodes[0].PrevSibling; n != nil; n = n.PrevSibling { + if n.Type == html.ElementNode { + i++ + } + } + return i } return -1 } diff --git a/vendor/github.com/PuerkitoBio/goquery/filter.go b/vendor/github.com/PuerkitoBio/goquery/filter.go index 9138ffb3..2964b8a4 100644 --- a/vendor/github.com/PuerkitoBio/goquery/filter.go +++ b/vendor/github.com/PuerkitoBio/goquery/filter.go @@ -12,7 +12,7 @@ func (s *Selection) Filter(selector string) *Selection { // the given matcher. It returns a new Selection object for this subset // of matching elements. func (s *Selection) FilterMatcher(m Matcher) *Selection { - return pushStack(s, winnow(s, m, true)) + return pushStack(s, winnow(s.Nodes, m, true)) } // Not removes elements from the Selection that match the selector string. @@ -24,7 +24,7 @@ func (s *Selection) Not(selector string) *Selection { // NotMatcher removes elements from the Selection that match the given matcher. // It returns a new Selection object with the matching elements removed. func (s *Selection) NotMatcher(m Matcher) *Selection { - return pushStack(s, winnow(s, m, false)) + return pushStack(s, winnow(s.Nodes, m, false)) } // FilterFunction reduces the set of matched elements to those that pass the function's test. @@ -79,29 +79,46 @@ func (s *Selection) Intersection(sel *Selection) *Selection { // that matches the selector. // It returns a new Selection object with the matching elements. func (s *Selection) Has(selector string) *Selection { - return s.HasSelection(s.document.Find(selector)) + return s.HasMatcher(compileMatcher(selector)) } // HasMatcher reduces the set of matched elements to those that have a descendant // that matches the matcher. // It returns a new Selection object with the matching elements. func (s *Selection) HasMatcher(m Matcher) *Selection { - return s.HasSelection(s.document.FindMatcher(m)) + result := make([]*html.Node, 0, len(s.Nodes)) + + // Manually create a singleMatcher (rather than using SingleMatcher, which + // returns a Matcher interface) so we can call its MatchFirst method + // directly. MatchFirst probes for the first match in a subtree without + // building a result slice, avoiding a throwaway one-element slice + // allocation for every matching child subtree. + sm := singleMatcher{m} + for _, n := range s.Nodes { + for c := n.FirstChild; c != nil; c = c.NextSibling { + if c.Type == html.ElementNode && sm.MatchFirst(c) != nil { + result = append(result, n) + break + } + } + } + return pushStack(s, result) } // HasNodes reduces the set of matched elements to those that have a // descendant that matches one of the nodes. // It returns a new Selection object with the matching elements. func (s *Selection) HasNodes(nodes ...*html.Node) *Selection { - return s.FilterFunction(func(_ int, sel *Selection) bool { - // Add all nodes that contain one of the specified nodes - for _, n := range nodes { - if sel.Contains(n) { - return true + var result []*html.Node + for _, n := range s.Nodes { + for _, candidate := range nodes { + if nodeContains(n, candidate) { + result = append(result, n) + break } } - return false - }) + } + return pushStack(s, result) } // HasSelection reduces the set of matched elements to those that have a @@ -125,33 +142,45 @@ func (s *Selection) End() *Selection { // Filter based on the matcher, and the indicator to keep (Filter) or // to get rid of (Not) the matching elements. -func winnow(sel *Selection, m Matcher, keep bool) []*html.Node { +func winnow(nodes []*html.Node, m Matcher, keep bool) []*html.Node { // Optimize if keep is requested if keep { - return m.Filter(sel.Nodes) + return m.Filter(nodes) } - // Use grep - return grep(sel, func(i int, s *Selection) bool { - return !m.Match(s.Get(0)) - }) + // Not path: call Match directly on each node, no Selection wrapper needed + result := make([]*html.Node, 0, len(nodes)) + for _, n := range nodes { + if !m.Match(n) { + result = append(result, n) + } + } + return result } // Filter based on an array of nodes, and the indicator to keep (Filter) or // to get rid of (Not) the matching elements. func winnowNodes(sel *Selection, nodes []*html.Node, keep bool) []*html.Node { if len(nodes)+len(sel.Nodes) < minNodesForSet { - return grep(sel, func(i int, s *Selection) bool { - return isInSlice(nodes, s.Get(0)) == keep - }) + var result []*html.Node + for _, n := range sel.Nodes { + if isInSlice(nodes, n) == keep { + result = append(result, n) + } + } + return result } - set := make(map[*html.Node]bool) + set := make(map[*html.Node]bool, len(nodes)) for _, n := range nodes { set[n] = true } - return grep(sel, func(i int, s *Selection) bool { - return set[s.Get(0)] == keep - }) + var result []*html.Node + for _, n := range sel.Nodes { + if set[n] == keep { + result = append(result, n) + } + } + return result } // Filter based on a function test, and the indicator to keep (Filter) or diff --git a/vendor/github.com/PuerkitoBio/goquery/manipulation.go b/vendor/github.com/PuerkitoBio/goquery/manipulation.go index 35febf11..202b02df 100644 --- a/vendor/github.com/PuerkitoBio/goquery/manipulation.go +++ b/vendor/github.com/PuerkitoBio/goquery/manipulation.go @@ -166,8 +166,16 @@ func (s *Selection) Clone() *Selection { // Empty removes all children nodes from the set of matched elements. // It returns the children nodes in a new Selection. func (s *Selection) Empty() *Selection { - var nodes []*html.Node + // Count the children first so nodes can be presized, avoiding append's + // repeated reallocations. + count := 0 + for _, n := range s.Nodes { + for c := n.FirstChild; c != nil; c = c.NextSibling { + count++ + } + } + nodes := make([]*html.Node, 0, count) for _, n := range s.Nodes { for c := n.FirstChild; c != nil; c = n.FirstChild { n.RemoveChild(c) @@ -374,20 +382,14 @@ func (s *Selection) WrapSelection(sel *Selection) *Selection { // // It returns the original set of elements. func (s *Selection) WrapHtml(htmlStr string) *Selection { - nodesMap := make(map[string][]*html.Node) - for _, context := range s.Nodes { - var parent *html.Node - if context.Parent != nil { - parent = context.Parent - } else { + cache := make(map[string][]*html.Node) + for _, n := range s.Nodes { + parent := n.Parent + if parent == nil { parent = &html.Node{Type: html.ElementNode} } - nodes, found := nodesMap[nodeName(parent)] - if !found { - nodes = parseHtmlWithContext(htmlStr, parent) - nodesMap[nodeName(parent)] = nodes - } - newSingleSelection(context, s.document).wrapAllNodes(cloneNodes(nodes)...) + nodes := cachedParseHtmlWithContext(cache, htmlStr, parent) + newSingleSelection(n, s.document).wrapAllNodes(cloneNodes(nodes)...) } return s } @@ -522,14 +524,10 @@ func (s *Selection) WrapInnerSelection(sel *Selection) *Selection { // // It returns the original set of elements. func (s *Selection) WrapInnerHtml(htmlStr string) *Selection { - nodesMap := make(map[string][]*html.Node) - for _, context := range s.Nodes { - nodes, found := nodesMap[nodeName(context)] - if !found { - nodes = parseHtmlWithContext(htmlStr, context) - nodesMap[nodeName(context)] = nodes - } - newSingleSelection(context, s.document).wrapInnerNodes(cloneNodes(nodes)...) + cache := make(map[string][]*html.Node) + for _, n := range s.Nodes { + nodes := cachedParseHtmlWithContext(cache, htmlStr, n) + newSingleSelection(n, s.document).wrapInnerNodes(cloneNodes(nodes)...) } return s } @@ -562,13 +560,7 @@ func (s *Selection) wrapInnerNodes(ns ...*html.Node) *Selection { } func parseHtml(h string) []*html.Node { - // Errors are only returned when the io.Reader returns any error besides - // EOF, but strings.Reader never will - nodes, err := html.ParseFragment(strings.NewReader(h), &html.Node{Type: html.ElementNode}) - if err != nil { - panic("goquery: failed to parse HTML: " + err.Error()) - } - return nodes + return parseHtmlWithContext(h, &html.Node{Type: html.ElementNode}) } func parseHtmlWithContext(h string, context *html.Node) []*html.Node { @@ -654,10 +646,9 @@ func (s *Selection) manipulateNodes(ns []*html.Node, reverse bool, // isParent can be used to indicate that the elements of the selection should be treated as the parent for the parsed html. // A cache is used to avoid parsing the html multiple times should the elements of the selection result in the same context. func (s *Selection) eachNodeHtml(htmlStr string, isParent bool, mergeFn func(n *html.Node, nodes []*html.Node)) *Selection { - // cache to avoid parsing the html for the same context multiple times - nodeCache := make(map[string][]*html.Node) - var context *html.Node + cache := make(map[string][]*html.Node) for _, n := range s.Nodes { + var context *html.Node if isParent { context = n.Parent } else { @@ -666,14 +657,24 @@ func (s *Selection) eachNodeHtml(htmlStr string, isParent bool, mergeFn func(n * } context = n } - if context != nil { - nodes, found := nodeCache[nodeName(context)] - if !found { - nodes = parseHtmlWithContext(htmlStr, context) - nodeCache[nodeName(context)] = nodes - } - mergeFn(n, cloneNodes(nodes)) + if context == nil { + continue } + nodes := cachedParseHtmlWithContext(cache, htmlStr, context) + mergeFn(n, cloneNodes(nodes)) } return s } + +// cachedParseHtmlWithContext returns parseHtmlWithContext(htmlStr, context), reusing a prior +// result when context's nodeName has already been seen. Callers pass their own +// cache map so the cache lifetime matches the caller's loop scope. +func cachedParseHtmlWithContext(cache map[string][]*html.Node, htmlStr string, context *html.Node) []*html.Node { + key := nodeName(context) + if nodes, ok := cache[key]; ok { + return nodes + } + nodes := parseHtmlWithContext(htmlStr, context) + cache[key] = nodes + return nodes +} diff --git a/vendor/github.com/PuerkitoBio/goquery/property.go b/vendor/github.com/PuerkitoBio/goquery/property.go index 25afceda..bda736a2 100644 --- a/vendor/github.com/PuerkitoBio/goquery/property.go +++ b/vendor/github.com/PuerkitoBio/goquery/property.go @@ -1,36 +1,31 @@ package goquery import ( - "regexp" "strings" "golang.org/x/net/html" ) -var rxClassTrim = regexp.MustCompile("[\t\r\n]") +var classTrimReplacer = strings.NewReplacer("\t", " ", "\r", " ", "\n", " ") // Attr gets the specified attribute's value for the first element in the // Selection. To get the value for each element individually, use a looping // construct such as Each or Map method. -func (s *Selection) Attr(attrName string) (val string, exists bool) { - if len(s.Nodes) == 0 { - return +func (s *Selection) Attr(attrName string) (string, bool) { + if len(s.Nodes) != 0 { + if attr := getAttributePtr(attrName, s.Nodes[0]); attr != nil { + return attr.Val, true + } } - return getAttributeValue(attrName, s.Nodes[0]) + return "", false } // AttrOr works like Attr but returns default value if attribute is not present. func (s *Selection) AttrOr(attrName, defaultValue string) string { - if len(s.Nodes) == 0 { - return defaultValue - } - - val, exists := getAttributeValue(attrName, s.Nodes[0]) - if !exists { - return defaultValue + if val, exists := s.Attr(attrName); exists { + return val } - - return val + return defaultValue } // RemoveAttr removes the named attribute from each element in the set of matched elements. @@ -60,27 +55,23 @@ func (s *Selection) SetAttr(attrName, val string) *Selection { // elements, including their descendants. func (s *Selection) Text() string { var builder strings.Builder - - // Slightly optimized vs calling Each: no single selection object created - var f func(*html.Node) - f = func(n *html.Node) { - if n.Type == html.TextNode { - // Keep newlines and spaces, like jQuery - builder.WriteString(n.Data) - } - if n.FirstChild != nil { - for c := n.FirstChild; c != nil; c = c.NextSibling { - f(c) - } - } - } for _, n := range s.Nodes { - f(n) + s.textHelper(n, &builder) } return builder.String() } +func (s *Selection) textHelper(n *html.Node, builder *strings.Builder) { + if n.Type == html.TextNode { + // Keep newlines and spaces, like jQuery + builder.WriteString(n.Data) + } + for c := n.FirstChild; c != nil; c = c.NextSibling { + s.textHelper(c, builder) + } +} + // Size is an alias for Length. func (s *Selection) Size() int { return s.Length() @@ -122,7 +113,7 @@ func (s *Selection) AddClass(class ...string) *Selection { tcls := getClassesSlice(classStr) for _, n := range s.Nodes { - curClasses, attr := getClassesAndAttr(n, true) + curClasses, attr := getClassesAndAttr(n) for _, newClass := range tcls { if !strings.Contains(curClasses, " "+newClass+" ") { curClasses += newClass + " " @@ -138,11 +129,20 @@ func (s *Selection) AddClass(class ...string) *Selection { // HasClass determines whether any of the matched elements are assigned the // given class. func (s *Selection) HasClass(class string) bool { + rawClass := class class = " " + class + " " for _, n := range s.Nodes { - classes, _ := getClassesAndAttr(n, false) - if strings.Contains(classes, class) { - return true + if n.Type != html.ElementNode { + continue + } + if attr := getAttributePtr("class", n); attr != nil { + if !strings.Contains(attr.Val, rawClass) { + continue + } + val := classTrimReplacer.Replace(attr.Val) + if strings.Contains(" "+val+" ", class) { + return true + } } } return false @@ -165,7 +165,7 @@ func (s *Selection) RemoveClass(class ...string) *Selection { if remove { removeAttr(n, "class") } else { - classes, attr := getClassesAndAttr(n, true) + classes, attr := getClassesAndAttr(n) for _, rcl := range rclasses { classes = strings.ReplaceAll(classes, " "+rcl+" ", " ") } @@ -189,7 +189,7 @@ func (s *Selection) ToggleClass(class ...string) *Selection { tcls := getClassesSlice(classStr) for _, n := range s.Nodes { - classes, attr := getClassesAndAttr(n, true) + classes, attr := getClassesAndAttr(n) for _, tcl := range tcls { spaceAroundTcl := " " + tcl + " " if strings.Contains(classes, spaceAroundTcl) { @@ -218,21 +218,12 @@ func getAttributePtr(attrName string, n *html.Node) *html.Attribute { return nil } -// Private function to get the specified attribute's value from a node. -func getAttributeValue(attrName string, n *html.Node) (val string, exists bool) { - if a := getAttributePtr(attrName, n); a != nil { - val = a.Val - exists = true - } - return -} - // Get and normalize the "class" attribute from the node. -func getClassesAndAttr(n *html.Node, create bool) (classes string, attr *html.Attribute) { +func getClassesAndAttr(n *html.Node) (classes string, attr *html.Attribute) { // Applies only to element nodes if n.Type == html.ElementNode { attr = getAttributePtr("class", n) - if attr == nil && create { + if attr == nil { n.Attr = append(n.Attr, html.Attribute{ Key: "class", Val: "", @@ -244,14 +235,14 @@ func getClassesAndAttr(n *html.Node, create bool) (classes string, attr *html.At if attr == nil { classes = " " } else { - classes = rxClassTrim.ReplaceAllString(" "+attr.Val+" ", " ") + classes = classTrimReplacer.Replace(" " + attr.Val + " ") } return } func getClassesSlice(classes string) []string { - return strings.Split(rxClassTrim.ReplaceAllString(" "+classes+" ", " "), " ") + return strings.Fields(classes) } func removeAttr(n *html.Node, attrName string) { diff --git a/vendor/github.com/PuerkitoBio/goquery/query.go b/vendor/github.com/PuerkitoBio/goquery/query.go index fe86bf0b..322b2f8b 100644 --- a/vendor/github.com/PuerkitoBio/goquery/query.go +++ b/vendor/github.com/PuerkitoBio/goquery/query.go @@ -11,32 +11,43 @@ func (s *Selection) Is(selector string) bool { // IsMatcher checks the current matched set of elements against a matcher and // returns true if at least one of these elements matches. func (s *Selection) IsMatcher(m Matcher) bool { - if len(s.Nodes) > 0 { - if len(s.Nodes) == 1 { - return m.Match(s.Nodes[0]) + for _, n := range s.Nodes { + if m.Match(n) { + return true } - return len(m.Filter(s.Nodes)) > 0 } - return false } // IsFunction checks the current matched set of elements against a predicate and // returns true if at least one of these elements matches. func (s *Selection) IsFunction(f func(int, *Selection) bool) bool { - return s.FilterFunction(f).Length() > 0 + for i, n := range s.Nodes { + if f(i, newSingleSelection(n, s.document)) { + return true + } + } + return false } // IsSelection checks the current matched set of elements against a Selection object // and returns true if at least one of these elements matches. func (s *Selection) IsSelection(sel *Selection) bool { - return s.FilterSelection(sel).Length() > 0 + if sel == nil { + return false + } + return s.IsNodes(sel.Nodes...) } // IsNodes checks the current matched set of elements against the specified nodes // and returns true if at least one of these elements matches. func (s *Selection) IsNodes(nodes ...*html.Node) bool { - return s.FilterNodes(nodes...).Length() > 0 + for _, n := range s.Nodes { + if isInSlice(nodes, n) { + return true + } + } + return false } // Contains returns true if the specified Node is within, diff --git a/vendor/github.com/PuerkitoBio/goquery/traversal.go b/vendor/github.com/PuerkitoBio/goquery/traversal.go index c45fa5db..da411403 100644 --- a/vendor/github.com/PuerkitoBio/goquery/traversal.go +++ b/vendor/github.com/PuerkitoBio/goquery/traversal.go @@ -149,7 +149,7 @@ func (s *Selection) ClosestMatcher(m Matcher) *Selection { // ClosestNodes gets the first element that matches one of the nodes by testing the // element itself and traversing up through its ancestors in the DOM tree. func (s *Selection) ClosestNodes(nodes ...*html.Node) *Selection { - set := make(map[*html.Node]bool) + set := make(map[*html.Node]bool, len(nodes)) for _, n := range nodes { set[n] = true } @@ -537,10 +537,7 @@ func (s *Selection) PrevMatcherUntilNodes(filter Matcher, nodes ...*html.Node) * // Filter and push filters the nodes based on a matcher, and pushes the results // on the stack, with the srcSel as previous selection. func filterAndPush(srcSel *Selection, nodes []*html.Node, m Matcher) *Selection { - // Create a temporary Selection with the specified nodes to filter using winnow - sel := &Selection{nodes, srcSel.document, nil} - // Filter based on matcher and push on stack - return pushStack(srcSel, winnow(sel, m, true)) + return pushStack(srcSel, winnow(nodes, m, true)) } // Internal implementation of Find that return raw nodes. @@ -562,13 +559,12 @@ func findWithMatcher(nodes []*html.Node, m Matcher) []*html.Node { func getParentsNodes(nodes []*html.Node, stopm Matcher, stopNodes []*html.Node) []*html.Node { return mapNodes(nodes, func(i int, n *html.Node) (result []*html.Node) { for p := n.Parent; p != nil; p = p.Parent { - sel := newSingleSelection(p, nil) if stopm != nil { - if sel.IsMatcher(stopm) { + if stopm.Match(p) { break } } else if len(stopNodes) > 0 { - if sel.IsNodes(stopNodes...) { + if isInSlice(stopNodes, p) { break } } @@ -589,13 +585,9 @@ func getSiblingNodes(nodes []*html.Node, st siblingType, untilm Matcher, untilNo if st == siblingNextUntil || st == siblingPrevUntil { f = func(n *html.Node) bool { if untilm != nil { - // Matcher-based condition - sel := newSingleSelection(n, nil) - return sel.IsMatcher(untilm) + return untilm.Match(n) } else if len(untilNodes) > 0 { - // Nodes-based condition - sel := newSingleSelection(n, nil) - return sel.IsNodes(untilNodes...) + return isInSlice(untilNodes, n) } return false } @@ -662,6 +654,20 @@ func getChildrenWithSiblingType(parent *html.Node, st siblingType, skipNode *htm } } + // For the cases that collect every matching sibling, count them in a + // cheap pointer walk first so the result slice can be sized exactly, + // avoiding repeated slice growth. The Until cases are skipped (counting + // would require running the predicate twice) and so are the single-result + // Next/Prev cases. + switch st { + case siblingAll, siblingAllIncludingNonElements, siblingPrevAll, siblingNextAll: + n := 0 + for c := iter(nil); c != nil; c = iter(c) { + n++ + } + result = make([]*html.Node, 0, n) + } + for c := iter(nil); c != nil; c = iter(c) { // If this is an ...Until case, test before append (returns true // if the until condition is reached) @@ -681,12 +687,21 @@ func getChildrenWithSiblingType(parent *html.Node, st siblingType, skipNode *htm // Internal implementation of parent nodes that return a raw slice of Nodes. func getParentNodes(nodes []*html.Node) []*html.Node { - return mapNodes(nodes, func(i int, n *html.Node) []*html.Node { - if n.Parent != nil && n.Parent.Type == html.ElementNode { - return []*html.Node{n.Parent} + // Collect parents inline rather than going through mapNodes, which would + // allocate a throwaway one-element slice per source node. Many source + // nodes (e.g. siblings) share the same parent, so deduplicate as we go. + var result []*html.Node + set := make(map[*html.Node]bool, len(nodes)) + + for _, n := range nodes { + p := n.Parent + if p == nil || p.Type != html.ElementNode || set[p] { + continue } - return nil - }) + set[p] = true + result = append(result, p) + } + return result } // Internal map function used by many traversing methods. Takes the source nodes @@ -694,7 +709,14 @@ func getParentNodes(nodes []*html.Node) []*html.Node { // Returns an array of nodes mapped by calling the callback function once for // each node in the source nodes. func mapNodes(nodes []*html.Node, f func(int, *html.Node) []*html.Node) (result []*html.Node) { - set := make(map[*html.Node]bool) + switch len(nodes) { + case 0: + return nil + case 1: + return f(0, nodes[0]) + } + + set := make(map[*html.Node]bool, len(nodes)) for i, n := range nodes { if vals := f(i, n); len(vals) > 0 { result = appendWithoutDuplicates(result, vals, set) diff --git a/vendor/github.com/PuerkitoBio/goquery/type.go b/vendor/github.com/PuerkitoBio/goquery/type.go index 6646c143..dd3778de 100644 --- a/vendor/github.com/PuerkitoBio/goquery/type.go +++ b/vendor/github.com/PuerkitoBio/goquery/type.go @@ -175,22 +175,31 @@ type singleMatcher struct { Matcher } -func (m singleMatcher) MatchAll(n *html.Node) []*html.Node { +// MatchFirst returns the first node that matches, or nil if none does. It uses +// the underlying Matcher's MatchFirst method if it provides one (cascadia- +// compiled matchers all do), avoiding building a result slice. Otherwise it +// falls back to MatchAll and returns its first element. +func (m singleMatcher) MatchFirst(n *html.Node) *html.Node { // Optimized version - stops finding at the first match (cascadia-compiled // matchers all use this code path). if mm, ok := m.Matcher.(interface{ MatchFirst(*html.Node) *html.Node }); ok { - node := mm.MatchFirst(n) - if node == nil { - return nil - } - return []*html.Node{node} + return mm.MatchFirst(n) } // Fallback version, for e.g. test mocks that don't provide the MatchFirst // method. nodes := m.Matcher.MatchAll(n) if len(nodes) > 0 { - return nodes[:1:1] + return nodes[0] + } + return nil +} + +func (m singleMatcher) MatchAll(n *html.Node) []*html.Node { + // Wrap MatchFirst's single result in a slice to respect the Matcher + // interface's MatchAll signature. + if node := m.MatchFirst(n); node != nil { + return []*html.Node{node} } return nil } diff --git a/vendor/github.com/PuerkitoBio/goquery/utilities.go b/vendor/github.com/PuerkitoBio/goquery/utilities.go index 361795b4..49f8dbe6 100644 --- a/vendor/github.com/PuerkitoBio/goquery/utilities.go +++ b/vendor/github.com/PuerkitoBio/goquery/utilities.go @@ -57,6 +57,72 @@ func nodeName(node *html.Node) string { } } +// TextOptions controls the behaviour of the Text function. +type TextOptions struct { + // Separator is inserted between the contents of the text nodes that are + // included in the result. It defaults to the empty string, which + // concatenates the text nodes without any separator. + Separator string + + // Trim, when true, removes leading and trailing whitespace from the + // content of each text node and omits text nodes that are empty once + // trimmed. This is useful to discard the insignificant whitespace that + // comes from the indentation of the source HTML. + Trim bool + + // Keep, when non-nil, is called for each text node encountered while + // traversing the selection. The content of the text node is included in + // the result only if Keep returns true. It can be used, for example, to + // drop the text of