From d83f20c3148dc037666784a90095bceb8199a733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 16 Sep 2021 13:30:12 +0200 Subject: [PATCH] Fix chi routing (#2076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-chi-routing.md | 5 +++++ internal/http/services/owncloud/ocs/ocs.go | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 changelog/unreleased/fix-chi-routing.md diff --git a/changelog/unreleased/fix-chi-routing.md b/changelog/unreleased/fix-chi-routing.md new file mode 100644 index 0000000000..e074dbd6ef --- /dev/null +++ b/changelog/unreleased/fix-chi-routing.md @@ -0,0 +1,5 @@ +Bugfix: Fix chi routing + +Chi routes based on the URL.RawPath, which is not updated by the shiftPath based routing used in reva. By setting the RawPath to an empty string chi will fall pack to URL.Path, allowing it to match percent encoded path segments, e.g. when trying to match emails or multibyte characters. + +https://github.com/cs3org/reva/pull/2076 diff --git a/internal/http/services/owncloud/ocs/ocs.go b/internal/http/services/owncloud/ocs/ocs.go index e50e9467ff..cb2b993135 100644 --- a/internal/http/services/owncloud/ocs/ocs.go +++ b/internal/http/services/owncloud/ocs/ocs.go @@ -138,6 +138,8 @@ func (s *svc) Handler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { log := appctx.GetLogger(r.Context()) log.Debug().Str("path", r.URL.Path).Msg("ocs routing") + // unset raw path, otherwise chi uses it to route and then fails to match percent encoded path segments + r.URL.RawPath = "" s.router.ServeHTTP(w, r) }) }