mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🍪 fix: input validation for lang cookie (#4024)
Co-authored-by: DanielAlt <daniel.altenburg@proton.me>
This commit is contained in:
parent
4ef5ae6f71
commit
c792e3279f
1 changed files with 2 additions and 1 deletions
|
|
@ -114,7 +114,8 @@ const startServer = async () => {
|
|||
app.use((req, res) => {
|
||||
// Replace lang attribute in index.html with lang from cookies or accept-language header
|
||||
const lang = req.cookies.lang || req.headers['accept-language']?.split(',')[0] || 'en-US';
|
||||
const updatedIndexHtml = indexHTML.replace(/lang="en-US"/g, `lang="${lang}"`);
|
||||
const saneLang = lang.replace(/"/g, '"'); // sanitize untrusted user input
|
||||
const updatedIndexHtml = indexHTML.replace(/lang="en-US"/g, `lang="${saneLang}"`);
|
||||
res.send(updatedIndexHtml);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue