Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: validate languages (#3638)

YidaHu7251748d599a
diff --git a/web/i18n/server.ts b/web/i18n/server.ts
index 54399a58a1d..933899e6a1f 100644
--- a/web/i18n/server.ts
+++ b/web/i18n/server.ts
@@ -46,6 +46,12 @@ export const getLocaleOnServer = (): Locale => {
languages = new Negotiator({ headers: negotiatorHeaders }).languages()
}
+ // Validate languages
+ if (!Array.isArray(languages) || languages.length === 0 || !languages.every(lang => typeof lang === 'string' && /^[\w-]+$/.test(lang))) {
+ console.error(`Invalid languages: ${languages}`)
+ languages = [i18n.defaultLocale]
+ }
+
// match locale
const matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
return matchedLocale