[ZBX-13673] Incorrect regular expression validation (at least in Icon Mapping) Created: 2018 Mar 29  Updated: 2018 Dec 11  Resolved: 2018 Dec 11

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 4.0.0alpha6
Fix Version/s: 4.0.3rc1, 4.2.0alpha2, 4.2 (plan)

Type: Problem report Priority: Minor
Reporter: Glebs Ivanovskis (Inactive) Assignee: Gregory Chalenko
Resolution: Fixed Votes: 0
Labels: iconmapping, regularexpression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File invalid_regular_expression.png    
Team: Team D
Sprint: Sprint 46, Nov 2018, Sprint 47, Dec 2018
Story Points: 0.5

 Description   

Steps to reproduce:

  1. Go to Administration→General
  2. Select Icon mapping
  3. Click Create icon map
  4. Enter some silly Name
  5. Enter / in Expression field
  6. Click Add button

Result:
See invalid_regular_expression.png

Cannot create icon map
Invalid parameter "/1/mappings/1/expression": invalid regular expression. [adm.iconmapping.php:70 ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? CIconMap->create() ? CIconMap->validateCreate() ? CApiService::exception() in include/classes/api/services/CIconMap.php:192]

Expected:
Icon map is successfully created because / is a valid regular expression (check it here), forward slash is not a special character.

Comments:
Even though forward slash is not a special character it needs to be escaped in the pattern if forward slash is also used as delimiter (which is a very common practice). Unfortunately, preg_quote() cannot be used here because we don't want to escape special characters user wants to provide in his/her pattern. The best approach would probably be to surround user pattern with parentheses, brackets or braces as suggested in this wonderful article.



 Comments   
Comment by Gregory Chalenko [ 2018 Nov 12 ]

RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBX-13673.

Comment by Gregory Chalenko [ 2018 Dec 05 ]

Fixed in:

  • 4.0.3rc1 r87560
  • 4.2.0alpha2 r87561
Generated at Thu Mar 28 14:39:12 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.