diff --git a/.github/scripts/setup_examples_test.bash b/.github/scripts/setup_examples_test.bash old mode 100755 new mode 100644 diff --git a/README.md b/README.md index e13fff46..844f8e00 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,6 @@ With your help, we can improve Open Source web development for everyone!
- @@ -153,164 +152,165 @@ With your help, we can improve Open Source web development for everyone! - - - - + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + + + + + + + + + + + + + + - + + + + + + + + + + + - - - - - + + + - + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + - - @@ -320,15 +320,15 @@ With your help, we can improve Open Source web development for everyone! - - + + + + + - - - diff --git a/core/router/fs.go b/core/router/fs.go index 057c9cbf..d6315cbb 100644 --- a/core/router/fs.go +++ b/core/router/fs.go @@ -384,7 +384,6 @@ func FileServer(fs http.FileSystem, options DirOptions) context.Handler { // match using relative path (without the first '/' slash) // to keep consistency between the `PushTargets` behavior if regex.MatchString(indexAsset) { - // println("Regex Matched: " + indexAsset) if err = pusher.Push(path.Join(prefixURL, indexAsset), pushOpts); err != nil { break @@ -588,8 +587,13 @@ func DirList(ctx *context.Context, dirOptions DirOptions, dirName string, dir ht name := toBaseName(d.Name()) - upath := path.Join(ctx.Request().RequestURI, name) - url := url.URL{Path: upath} + u, err := url.Parse(ctx.Request().RequestURI) // clone url and remove query (#1882). + if err != nil { + return fmt.Errorf("name: %s: error: %w", name, err) + } + u.RawQuery = "" + + upath := url.URL{Path: path.Join(u.String(), name)} downloadAttr := "" if dirOptions.Attachments.Enable && !d.IsDir() { @@ -608,7 +612,7 @@ func DirList(ctx *context.Context, dirOptions DirOptions, dirName string, dir ht "%s"+ "%s"+ "", - d.Mode().String(), url.String(), downloadAttr, html.EscapeString(viewName)) + d.Mode().String(), upath.String(), downloadAttr, html.EscapeString(viewName)) if err != nil { return err } @@ -667,8 +671,13 @@ func DirListRich(opts ...DirListRichOptions) DirListFunc { name := toBaseName(d.Name()) - upath := path.Join(ctx.Request().RequestURI, name) - url := url.URL{Path: upath} + u, err := url.Parse(ctx.Request().RequestURI) // clone url and remove query (#1882). + if err != nil { + return fmt.Errorf("name: %s: error: %w", name, err) + } + u.RawQuery = "" + + upath := url.URL{Path: path.Join(u.String(), name)} viewName := name if d.IsDir() { @@ -679,7 +688,7 @@ func DirListRich(opts ...DirListRichOptions) DirListFunc { pageData.Files = append(pageData.Files, fileInfoData{ Info: d, ModTime: d.ModTime().UTC().Format(http.TimeFormat), - Path: url.String(), + Path: upath.String(), RelPath: path.Join(ctx.Path(), name), Name: html.EscapeString(viewName), Download: shouldDownload, @@ -1128,8 +1137,10 @@ type file struct { info os.FileInfo } -var _ http.File = (*file)(nil) -var _ cacheStoreFile = (*file)(nil) +var ( + _ http.File = (*file)(nil) + _ cacheStoreFile = (*file)(nil) +) func newFile(name string, fi os.FileInfo, algs map[string][]byte) *file { return &file{ @@ -1243,8 +1254,10 @@ type dir struct { children []os.FileInfo // a slice of *fileInfo } -var _ os.FileInfo = (*dir)(nil) -var _ http.File = (*dir)(nil) +var ( + _ os.FileInfo = (*dir)(nil) + _ http.File = (*dir)(nil) +) func (d *dir) Close() error { return nil } func (d *dir) Name() string { return d.baseName } diff --git a/go.mod b/go.mod index adceef30..ccdbc7cd 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/fatih/structs v1.1.0 github.com/flosch/pongo2/v4 v4.0.2 github.com/go-redis/redis/v8 v8.11.5 - github.com/goccy/go-json v0.9.8-0.20220503045905-3fdc55a60ade + github.com/goccy/go-json v0.9.8-0.20220506185958-23bd66f4c0d5 github.com/golang/snappy v0.0.4 github.com/google/uuid v1.3.0 github.com/gorilla/securecookie v1.1.1 @@ -30,7 +30,7 @@ require ( github.com/kataras/pio v0.0.10 github.com/kataras/sitemap v0.0.5 github.com/kataras/tunnel v0.0.3 - github.com/klauspost/compress v1.15.2 + github.com/klauspost/compress v1.15.3 github.com/mailgun/raymond/v2 v2.0.46 github.com/mailru/easyjson v0.7.7 github.com/microcosm-cc/bluemonday v1.0.18 @@ -41,7 +41,7 @@ require ( github.com/vmihailenco/msgpack/v5 v5.3.5 github.com/yosssi/ace v0.0.5 go.etcd.io/bbolt v1.3.6 - golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f + golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 golang.org/x/text v0.3.7 diff --git a/go.sum b/go.sum index d822e721..f02afc73 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA= github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= -github.com/goccy/go-json v0.9.8-0.20220503045905-3fdc55a60ade h1:fOvdX6bkHSj2xhunHCz9cwTh5f2tZPqiK7hwXbibsDI= -github.com/goccy/go-json v0.9.8-0.20220503045905-3fdc55a60ade/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.9.8-0.20220506185958-23bd66f4c0d5 h1:aeyOtISssR4sP36FAC9LV96PQqxzcbhz54EWv9U+ZGc= +github.com/goccy/go-json v0.9.8-0.20220506185958-23bd66f4c0d5/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= @@ -122,8 +122,8 @@ github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubc github.com/kataras/tunnel v0.0.3 h1:+8eHXujPD3wLnqTbYtPGa/3/Jc+Eq+bsPwEGTeFBB00= github.com/kataras/tunnel v0.0.3/go.mod h1:VOlCoaUE5zN1buE+yAjWCkjfQ9hxGuhomKLsjei/5Zs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.15.2 h1:3WH+AG7s2+T8o3nrM/8u2rdqUEcQhmga7smjrT41nAw= -github.com/klauspost/compress v1.15.2/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.15.3 h1:wmfu2iqj9q22SyMINp1uQ8C2/V4M1phJdmH9fG4nba0= +github.com/klauspost/compress v1.15.3/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -244,8 +244,8 @@ go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc= -golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 h1:NvGWuYG8dkDHFSKksI1P9faiVJ9rayE6l0+ouWVIDs8= +golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 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= diff --git a/x/errors/path_type_parameter_error_handler.go b/x/errors/path_parameter_type_error_handler.go similarity index 72% rename from x/errors/path_type_parameter_error_handler.go rename to x/errors/path_parameter_type_error_handler.go index 2e4125e4..c9036571 100644 --- a/x/errors/path_type_parameter_error_handler.go +++ b/x/errors/path_parameter_type_error_handler.go @@ -5,9 +5,9 @@ import ( "github.com/kataras/iris/v12/macro/handler" ) -// DefaultPathTypeParameterErrorHandler registers an error handler for macro path type parameter. -// Register it with Application.Macros().SetErrorHandler(DefaultPathTypeParameterErrorHandler). -var DefaultPathTypeParameterErrorHandler handler.ParamErrorHandler = func(ctx *context.Context, paramIndex int, err error) { +// DefaultPathParameterTypeErrorHandler registers an error handler for macro path type parameter. +// Register it with Application.Macros().SetErrorHandler(DefaultPathParameterTypeErrorHandler). +var DefaultPathParameterTypeErrorHandler handler.ParamErrorHandler = func(ctx *context.Context, paramIndex int, err error) { param := ctx.Params().GetEntryAt(paramIndex) // key, value fields. InvalidArgument.DataWithDetails(ctx, "invalid path parameter", err.Error(), param) }