Skip to content

Commit 700aa2a

Browse files
committed
fix(auth): make PHP config parser robust against missing quotes
- Replaced brittle explode() logic in getConfigValue with a robust array split. - Prevents PHP 'Undefined array key 1' fatal warnings which were crashing DataTables and causing 403 Forbidden redirects in the UI.
1 parent 25487ef commit 700aa2a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

front/php/templates/security.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ function getConfigLine($pattern, $config_lines) {
2626
return !empty($matches) ? explode("=", array_values($matches)[0]) : null;
2727
}
2828

29-
function getConfigValue($pattern, $config_lines, $delimiter = "'") {
29+
function getConfigValue($pattern, $config_lines) {
3030
$line = preg_grep($pattern, $config_lines);
31-
return !empty($line) ? explode($delimiter, array_values($line)[0])[1] : '';
31+
if (empty($line)) return '';
32+
$val = explode('=', array_values($line)[0], 2);
33+
if (!isset($val[1])) return '';
34+
return trim(trim($val[1]), "\"'");
3235
}
3336

3437
function redirect($url) {
@@ -93,7 +96,7 @@ function redirect($url) {
9396
$nax_WebProtection = 'true';
9497
}
9598
$nax_Password = getConfigValue('/^SETPWD_password\s*=/', $configLines);
96-
$api_token = getConfigValue('/^API_TOKEN\s*=/', $configLines, "'");
99+
$api_token = getConfigValue('/^API_TOKEN\s*=/', $configLines);
97100
if (empty($api_token)) {
98101
$api_token = getenv('API_TOKEN') ?: '';
99102
}

0 commit comments

Comments
 (0)