public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] Check cookie content, fixes #1917
7490a85a
data/web/inc/prerequisites.inc.php | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Diff
diff --git a/data/web/inc/prerequisites.inc.php b/data/web/inc/prerequisites.inc.php
index 67f72b78..4296c837 100644
--- a/data/web/inc/prerequisites.inc.php
+++ b/data/web/inc/prerequisites.inc.php
@@ -112,11 +112,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';
// Set language
if (!isset($_SESSION['mailcow_locale']) && !isset($_COOKIE['mailcow_locale'])) {
if ($DETECT_LANGUAGE && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- $header_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
- foreach ($AVAILABLE_LANGUAGES as $available_lang) {
- if ($header_lang == $available_lang) {
- $_SESSION['mailcow_locale'] = strtolower(trim($header_lang));
- }
+ $header_lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
+ if (in_array($header_lang, $AVAILABLE_LANGUAGES)) {
+ $_SESSION['mailcow_locale'] = $header_lang;
}
}
else {
@@ -124,7 +122,7 @@ if (!isset($_SESSION['mailcow_locale']) && !isset($_COOKIE['mailcow_locale'])) {
}
}
if (isset($_COOKIE['mailcow_locale'])) {
- $_SESSION['mailcow_locale'] = $_COOKIE['mailcow_locale'];
+ (preg_match('/^[a-z]{2}$/', $_COOKIE['mailcow_locale'])) ? $_SESSION['mailcow_locale'] = $_COOKIE['mailcow_locale'] : setcookie("mailcow_locale", "", time() - 300);
}
if (isset($_GET['lang']) && in_array($_GET['lang'], $AVAILABLE_LANGUAGES)) {
$_SESSION['mailcow_locale'] = $_GET['lang'];