helm / helm/chartmuseum

Fail to parse Unicode

Open
#275 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.8k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

Hey guys,
Found a bug in the parsing of GET request parameters
```
2019/09/23 12:08:07 [Recovery] 2019/09/23 - 12:08:07 panic recovered:
regexp: Compile("(^.*?)/\\b\xc1\xc1E\\.tgz\\.tgz\\b(.*$)"): error parsing regexp: invalid UTF-8: `??E\.tgz\.tgz\b(.*$)`
/usr/local/Cellar/go/1.13/libexec/src/regexp/regexp.go:311 (0x13cc631)
MustCompile: panic(`regexp: Compile(` + quote(str) + `): ` + err.Error())
/Users/asasson/go/src/github.com/chartmuseum/pkg/chartmuseum/router/router.go:236 (0x1cb4583)
mapURLWithParamsBackToRouteTemplate: re := regexp.MustCompile(fmt.Sprintf(`(^.*?)/\b%s\b(.*$)`, regexp.QuoteMeta(p.Value)))
/Users/asasson/go/pkg/mod/github.com/zsais/go-gin-prometheus@v0.0.0-20181030200533-58963fb32f54/middleware.go:371 (0x1cb07cf)
(*Prometheus).HandlerFunc.func1: url := p.ReqCntURLLabelMappingFn(c)
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x1c0ed6a)
(*Context).Next: c.handlers[c.index](c)
/Users/asasson/go/pkg/mod/github.com/gin-contrib/size@v0.0.0-20190528085907-355431950c57/size.go:88 (0x1c5ed04)
RequestSizeLimiter.func1: ctx.Next()
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x1c0ed6a)
(*Context).Next: c.handlers[c.index](c)
/Users/asasson/go/src/github.com/chartmuseum/pkg/chartmuseum/router/middleware.go:48 (0x1cb4778)
requestWrapper.func1: c.Next()
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x1c0ed6a)
(*Context).Next: c.handlers[c.index](c)
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/recovery.go:83 (0x1c22163)
RecoveryWithWriter.func1: c.Next()
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x1c0ed6a)
(*Context).Next: c.handlers[c.index](c)
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:425 (0x1c186f7)
serveError: c.Next()
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:418 (0x1c18418)
(*Engine).handleHTTPRequest: serveError(c, http.StatusNotFound, default404Body)
/Users/asasson/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:351 (0x1c17e53)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/Cellar/go/1.13/libexec/src/net/http/server.go:2802 (0x12f2713)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/Cellar/go/1.13/libexec/src/net/http/server.go:1890 (0x12edfb4)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/Cellar/go/1.13/libexec/src/runtime/asm_amd64.s:1357 (0x105ad20)
goexit: BYTE $0x90 // NOP
```

Python code for reproduction -
```
import requests
requests.get("http://localhost:8080/charts/" + "%c1%c1" + ".tgz")
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.