From b26784245ab437b242c8f9d38527c2014d71f2e9 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Mon, 27 Mar 2023 21:07:27 +0200 Subject: [PATCH] change language code validation --- changelog/unreleased/fix-app-provider-lang.md | 6 ++++++ internal/http/services/appprovider/appprovider.go | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-app-provider-lang.md diff --git a/changelog/unreleased/fix-app-provider-lang.md b/changelog/unreleased/fix-app-provider-lang.md new file mode 100644 index 0000000000..3fb78d1e27 --- /dev/null +++ b/changelog/unreleased/fix-app-provider-lang.md @@ -0,0 +1,6 @@ +Bugfix: Fix app provider language validation + +This changes the validation to only look at the first part (tag) of the language code and ignore the second part (sub-tag). + + +https://github.com/cs3org/reva/pull/3755 diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index 0b34bea18f..1f79b14f19 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -366,8 +366,9 @@ func (s *svc) handleOpen(openMode int) http.HandlerFunc { } lang := r.Form.Get("lang") - if lang != "" && !iso6391.ValidCode(lang) { - writeError(w, r, appErrorInvalidParameter, "lang parameter does not contain a valid ISO 639-1 language code", nil) + parts := strings.Split(lang, "_") + if lang != "" && !iso6391.ValidCode(parts[0]) { + writeError(w, r, appErrorInvalidParameter, "lang parameter does not contain a valid ISO 639-1 language code in the language tag", nil) return }