Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-13673

Incorrect regular expression validation (at least in Icon Mapping)

XMLWordPrintable

    • Sprint 46, Nov 2018, Sprint 47, Dec 2018
    • 0.5

      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.

            gcalenko Gregory Chalenko
            glebs.ivanovskis Glebs Ivanovskis (Inactive)
            Team D
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: