4.91v Restricted replaceable variables

Last modification: 2026-09-07 11:43:29

1. Notable changes since 4.90v
   - Chat widget CAPTCHA providers: added Google reCAPTCHA v3 and Cloudflare Turnstile support for verifying chat widget visitors through provider-based CAPTCHA validation; CAPTCHA settings gained a chat-specific enable flag and a configurable reCAPTCHA v3 score threshold; a dedicated widget CAPTCHA helper loads the provider script and resolves the token, which is now sent and verified as part of the widget online chat submission; the CAPTCHA settings screen gained a provider toggle and CAPTCHA settings are exposed through the widget online settings endpoint.
   - Canned message replaceable variables: added a `configuration` field to `lh_canned_msg_replace` storing per-variable JSON options to hide the variable value from the replaceable variables list ("Hide value in list") and to restrict management of the variable to operators holding the new `use_replace_sensitive` permission of the `lhcannedmsg` module ("Restricted access"); restricted variables show a "Restricted" badge, their value and clone/edit/delete actions are hidden from operators without the permission, and access control is enforced in the clone, edit and delete handlers.
   - Exact counts for chat and mail searches: the chat and mail conversation search panels gained an "Exact count" toggle; by default the result total is capped by counting only the first 1,000 matching rows through new `limit_count` support in `getCount()`, avoiding slow full-table scans on large result sets, and the paginator shows an approximate total ("~") whenever the count was capped; enabling "Exact count" performs a precise count of every matching row.
   - Bot REST API actions: authentication credentials used for NTLM, Bearer token and API key (header and query parameter) requests now resolve through replaceable variables; authorization headers are masked in debug logs by shortening them from both sides so secrets are not exposed; new user language dynamic variables (`{{user_locale}}`, `{{user_site_access}}`, `{{user_content_language}}`, `{{user_content_language_name}}`) were added for REST API bot actions, backed by a new `user_language` magic property on the chat model; streaming requests gained a configurable row start pattern so response streams that do not use the SSE `data: {` prefix are parsed correctly.
   - Bot trigger arguments: invisible message arguments (`{message_invisible_N}`) passed from the widget are now consistently forwarded to every trigger execution path, including theme-based bot trigger execution and the default trigger, by centralizing trigger argument processing early in the widget online submission flow.
   - Offline reasons for operators: the offline reasons feature now supports operator access control through a new `offlinereasons_operator` permission that can be granted with limitations restricting operators to specific reasons; the status (online/offline) modal shows a reason selector when an operator goes offline and stores the selection as `offline_reason_id`, and only the reasons an operator is allowed to use are exposed in the dashboard and status modal; the permission editor and "who grants" summary show the offline-reason limitation, specific function limitations are now respected over wildcard grants, and offline reasons can be deleted.
   - Statistics averages: agent statistics averages now include the full result set instead of trimming the highest and lowest ten percent, and preserve fractional values when computing the averages.
   - Security hardening: file downloads in incoming webhooks and online-user avatar fetching were hardened against SSRF - only HTTP/HTTPS URLs are accepted, `localhost` and private/reserved IP addresses are rejected, the resolved hostname is pinned to a validated IP to prevent DNS rebinding, and redirect following is disabled; message validation and the message preview modal were fixed.
   - Reliability: the bot "Close chat" command now runs inside a database transaction with row locking to prevent race conditions and partial state updates during chat closure; the mail conversation fetch API returns an error instead of failing fatally when the conversation cannot be found; mailbox syncing now limits SQL statement execution and lock-wait time and sets IMAP open/read/write/close timeouts so a slow mail server cannot stall the sync process.
   - Message masking test tool: added a chat-context simulation mode where a chat and a test message are supplied and the tool reproduces the real widget masking flow with step-by-step diagnostics (chat found, guardrails enabled, chat assigned to operator, matching masking rule, operator permission, masking result) using the chat's department, assigned operator and permissions, along with clearer explanations.
   - Miscellaneous: added RAR and other MIME type detection for downloaded webhook attachments; added Latvian (`lv_LV`) and Estonian (`et_EE`) translations and updated the translation update script; widened the widget theme custom CSS fields from `text` to `mediumtext` to prevent CSS truncation; updated install scripts and database structure definitions; bumped version to 4.91v.

2. Summary
   - This release focuses on safeguarding sensitive data, richer chat widget CAPTCHA options, and performance tuning for large searches.
   - Chat widget visitors can now be verified with Google reCAPTCHA v3 or Cloudflare Turnstile, controlled by a chat-specific CAPTCHA switch and a configurable score threshold.
   - Canned message replaceable variables can hide their values from lists and be locked down to operators with a dedicated permission.
   - Chat and mail searches gain an "Exact count" option while default counts are capped and marked approximate for large result sets.
   - Bot REST API actions support variable-based authentication with masked secrets, user language variables, and flexible streaming row parsing, and invisible message arguments now reach all trigger workflows.
   - Offline reasons become permission-controlled, file downloads are hardened against SSRF, and mail fetching, chat closing, statistics averaging and translation coverage were improved.

For update just follow standard update procedure. For manual update it's update_357.sql

**Full Changelog**: https://github.com/LiveHelperChat/livehelperchat/compare/4.90v...4.91v