-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
STEPS TO REPRODUCE
Run application from e.g. standard Windows path like "C:\Program Files (x86)\AppName".
ACTUAL RESULT
panic: Invalid schema provided to SchemaValidator: open c:\program files (x86)\AppName\.root: The system cannot find the file specified.
goroutine 6 [running]:
github.com/go-openapi/validate.NewSchemaValidator(0xc000422000, 0xb86960, 0xc0000ca900, 0xc000405d10, 0x4, 0xcfbba0, 0xc00015f1d0, 0x0, 0x0, 0x0, ...)
AppName/pkg/mod/github.com/go-openapi/[email protected]/schema.go:72 +0x100a
github.com/go-openapi/runtime/middleware.newUntypedParamBinder(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/parameter.go:47 +0x198
github.com/go-openapi/runtime/middleware.NewUntypedRequestBinder(0xc0004ab0b0, 0xc0000ca900, 0xcfbba0, 0xc00015f1d0, 0xc0004ab110)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/request.go:40 +0x14f
github.com/go-openapi/runtime/middleware.(*defaultRouteBuilder).AddRoute(0xc000079c78, 0xbf2c66, 0x4, 0xc00049dee0, 0x6, 0xc0000d5180)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/router.go:442 +0x600
github.com/go-openapi/runtime/middleware.DefaultRouter(0xc00004bc70, 0xcfdca0, 0xc0003ca4e0, 0xb69580, 0xc0004a4dc0)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/router.go:141 +0x15b
github.com/go-openapi/runtime/middleware.NewRouter(0xc0004aa900, 0xce90c0, 0xc0004a4dc0, 0xc0004a4dc0, 0xc2e890)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/router.go:73 +0xe9
github.com/go-openapi/runtime/middleware.(*Context).RoutesHandler(0xc0004aa900, 0xc2da48, 0xc2e860, 0xc2e858)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/context.go:621 +0x84
github.com/go-openapi/runtime/middleware.(*Context).APIHandler(0xc0004aa900, 0x0, 0x0, 0x0)
AppName/pkg/mod/github.com/go-openapi/[email protected]/middleware/context.go:612 +0x102
..........
AppName code
EXPECTED RESULT
You can place GO application in paths with parentheses or blanks.
ROOT CAUSE
Parentheses in paths are encoded in schemaLoader cache but they are compared with not encoded paths in the "func (r *schemaLoader) load(refURL *url.URL)". Possible fix is:
func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error) {
debugLog("loading schema from url: %s", refURL)
toFetch := *refURL
toFetch.Fragment = ""
var err error
pth := toFetch.String()
normalized := normalizeBase(pth)
debugLog("loading doc from: %s", normalized)
+ unescaped, err := url.PathUnescape(normalized)
+ if err != nil {
+ return nil, url.URL{}, false, err
+ }
+ u := url.URL{Path: unescaped}
- data, fromCache := r.cache.Get(normalized)
+ data, fromCache := r.cache.Get(u.RequestURI())
if fromCache {
return data, toFetch, fromCache, nil
}
Metadata
Metadata
Assignees
Labels
No labels