[ZBX-26207] Trailing and leading spaces are not trimmed in "Macro" field when switching to "Inherited and host macros" view Created: 2025 Mar 20  Updated: 2025 Mar 24  Resolved: 2025 Mar 24

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 7.0.12rc1, 7.2.6rc1, 7.4.0beta1 (master)
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Sergejs Olonkins Assignee: Zabbix Development Team
Resolution: Won't fix Votes: 0
Labels: macro, trailingspaces, trim
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: GIF File macro_not_trimmed_when_switching_modes.gif    

 Description   

Problem description: Trailing and leading spaces are not trimmed in "Macro" field when switching from "Host macros" to "Inherited and host macros" view.
As result, if Macro name differs only by this trailing/leading space in respect to an inherited macro name (user tried to override the value) then these 2 macros will be considered as different entries in the "Inherited and host macros" view.

Steps to reproduce:

  1. Open configuration of any host
  2. Switch to Macros tab
  3. Specify a macro that coincides with some global macro, but with a trailing space (for example "{$SNMP_COMMUNITY} ")
  4. Switch to "Inherited and host macros" view
  5. Check the entries for the {$SNMP_COMMUNITY} macro

Result: two entries exist for the {$SNMP_COMMUNITY} as the trailing space was not trimmed.
Expected: trailing and leading spaces should be trimmed when switching from "Host macros" to "Inherited and host macros" view.

Example:



 Comments   
Comment by Alexander Vladishev [ 2025 Mar 24 ]

Whitespace trimming should not occur when switching macro display modes. We don't know why the user entered those spaces — for example, they might not have finished writing a macro with a context that includes trailing spaces:

{$MACRO: "context with trailing spaces<SPACE><SPACE><SPACE>

Trimming spaces in this case would result in the removal of spaces from an incomplete macro, which may not be what the user intended.

Generated at Sun Mar 30 10:45:30 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.