Files
zoneminder/web/ajax/monitor.php
T
Isaac ConnorandClaude Opus 4.8 03f3af3d36 fix: replace Cyrillic С with Latin C in monitor ajax error message
web/ajax/monitor.php built its permission-error text with
translate('СonjOr'), where the leading С is Cyrillic Es (U+0421), not
Latin C. Two consequences:

- The lookup key did not match the defined 'ConjOr' translation (Latin C,
  en_gb.php), so translate() fell through to echoing the raw key instead of
  the conjunction "or".
- The multi-byte UTF-8 sequence (0xD0 0xA1) is corrupted by some reverse
  proxies, surfacing as a stray control byte in the served response.

Use the Latin 'ConjOr' key, matching every other caller (e.g.
web/includes/FilterTerm.php). A full Cyrillic/Greek homoglyph sweep of the
first-party tree (excluding lang/ and vendored assets) found this as the
only remaining occurrence.

refs https://github.com/ZoneMinder/zoneminder/discussions/4993

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQipwf632JGgNH4W7p8cqs
2026-07-19 23:16:48 -04:00

43 lines
1.8 KiB
PHP

<?php
ini_set('display_errors', '0');
if ( canView('Monitors') || (isset($_REQUEST['mid']) && $_REQUEST['mid'] !== '' && canView('Monitors', $_REQUEST['mid'])) ) {
$mid = isset($_REQUEST['mid']) ? $_REQUEST['mid'] : null;
if ($mid === null || $mid === '') {
ajaxError(translate('RequestMissing') . ' "mid".');
}
$action = $_REQUEST['action'] ?? '';
if ($action === '') {
ajaxError(translate('RequestMissing') . ' "action".');
}
switch ( $action ) {
case 'validateName' :
require_once('includes/Monitor.php');
$monitor = new ZM\Monitor($mid);
$filterRegexp = $monitor->getDefaults()['Name']['filter_regexp'];
$result = true;
$badChars = [];
$message = '';
if (isset($_REQUEST['monitorName']) && is_string($_REQUEST['monitorName']) && $_REQUEST['monitorName'] !== '') {
$monitorName = $_REQUEST['monitorName'];
$trimmedMonitorName = trim($monitorName);
$cleanedMonitorName = preg_replace($filterRegexp, '', $trimmedMonitorName);
if ($trimmedMonitorName != $cleanedMonitorName){
preg_match_all($filterRegexp, $trimmedMonitorName, $badChars);
$result = false;
$message = translate('BadNameCharsList') . ' "' . implode('","', array_unique($badChars[0])) . '".~~' . translate('BadNameChars');
}
ajaxResponse(array('response'=>$result, 'monitorName'=>$monitorName, 'cleanedMonitorName'=>$cleanedMonitorName, 'badChars'=>$badChars, 'messageBadNameChars'=>$message));
} else {
ajaxError(translate('ErrorVerifyingMonitorName'));
}
break;
} // end switch action
} // end if canView('Monitors')
ajaxError(translate('UnrecognisedAction').' "'.validHtmlStr($_REQUEST['action'] ?? '').'" '.translate('ConjOr').' '.translate('insufficientPermissionsUser').' "'.validHtmlStr($user->Username()).'"');
?>