From 9f5faa7cf80ae39edb5b2a103810e50cb2829cde Mon Sep 17 00:00:00 2001 From: perennial Date: Fri, 11 Oct 2024 15:07:01 +1100 Subject: [PATCH] fix broken /proxy/i.pximg.net setting --- go.mod | 3 --- go.sum | 7 ------- server/routes/about.go | 2 +- server/routes/settings.go | 2 +- server/routes/types.go | 5 +++-- server/session/aux.go | 6 +++--- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index c7fa20b..4e3aa73 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/go-faker/faker/v4 v4.5.0 github.com/goccy/go-json v0.10.3 github.com/gorilla/mux v1.8.1 - github.com/goware/urlx v0.3.2 github.com/hashicorp/go-retryablehttp v0.7.7 github.com/oklog/ulid/v2 v2.1.0 github.com/sethvargo/go-envconfig v1.1.0 @@ -29,8 +28,6 @@ require ( require ( github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/tidwall/match v1.1.1 // indirect diff --git a/go.sum b/go.sum index b79b705..276ac64 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,6 @@ github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oM github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4= github.com/PuerkitoBio/goquery v1.10.0 h1:6fiXdLuUvYs2OJSvNRqlNPoBm6YABE226xrbavY5Wv4= github.com/PuerkitoBio/goquery v1.10.0/go.mod h1:TjZZl68Q3eGHNBA8CWaxAN7rOU1EbDz3CWuolcO5Yu4= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -22,8 +18,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/goware/urlx v0.3.2 h1:gdoo4kBHlkqZNaf6XlQ12LGtQOmpKJrR04Rc3RnpJEo= -github.com/goware/urlx v0.3.2/go.mod h1:h8uwbJy68o+tQXCGZNa9D73WN8n0r9OBae5bUnLcgjw= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= @@ -68,7 +62,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 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= diff --git a/server/routes/about.go b/server/routes/about.go index 4118f52..ececedc 100644 --- a/server/routes/about.go +++ b/server/routes/about.go @@ -13,7 +13,7 @@ func AboutPage(w http.ResponseWriter, r *http.Request) error { RepoURL: config.GlobalConfig.RepoURL, Revision: config.GlobalConfig.Revision, RevisionHash: config.GlobalConfig.RevisionHash, // Used for the link to the source code repo - ImageProxy: config.GlobalConfig.ProxyServer.String(), + ImageProxy: config.GlobalConfig.ProxyServer, AcceptLanguage: config.GlobalConfig.AcceptLanguage, }) } diff --git a/server/routes/settings.go b/server/routes/settings.go index d0df858..7ede930 100644 --- a/server/routes/settings.go +++ b/server/routes/settings.go @@ -196,7 +196,7 @@ func SettingsPage(w http.ResponseWriter, r *http.Request) error { ProxyList: config.BuiltinProxyList, ProxyCheckEnabled: config.GlobalConfig.ProxyCheckEnabled, // Used to check whether proxy_checker is enabled on the instance ProxyCheckInterval: config.GlobalConfig.ProxyCheckInterval, // Used to display the ProxyCheckInterval configured on the instance - DefaultProxyServer: config.GlobalConfig.ProxyServer.String(), // Used to display the default image proxy server + DefaultProxyServer: config.GlobalConfig.ProxyServer, // Used to display the default image proxy server }) } diff --git a/server/routes/types.go b/server/routes/types.go index 38a61ab..e03b075 100644 --- a/server/routes/types.go +++ b/server/routes/types.go @@ -2,6 +2,7 @@ package routes import ( "net/http" + "net/url" "codeberg.org/vnpower/pixivfe/v2/core" "codeberg.org/vnpower/pixivfe/v2/server/request_context" @@ -33,7 +34,7 @@ type Data_about struct { RepoURL string Revision string RevisionHash string - ImageProxy string + ImageProxy url.URL AcceptLanguage string } type Data_artwork struct { @@ -138,7 +139,7 @@ type Data_settings struct { WorkingProxyList []string ProxyCheckEnabled bool ProxyCheckInterval time.Duration - DefaultProxyServer string + DefaultProxyServer url.URL } type Data_tag struct { Title string diff --git a/server/session/aux.go b/server/session/aux.go index cdc7696..3761a46 100644 --- a/server/session/aux.go +++ b/server/session/aux.go @@ -8,8 +8,6 @@ import ( "net/url" "strings" - "github.com/goware/urlx" - "codeberg.org/vnpower/pixivfe/v2/config" ) @@ -24,7 +22,9 @@ func GetImageProxy(r *http.Request) url.URL { if value == "" { // fall through to default case } else { - proxyUrl, err := urlx.Parse(value) + // NOTE: do not use urlx for parsing here, a URI path like /proxy/i.pximg.net will fail to parse + // This will cause the default ProxyServer be silently used instead despite a UI change on the Settings page + proxyUrl, err := url.Parse(value) if err != nil { // fall through to default case } else {