Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4790

regsubst incompatibility between puppet 3.x and 4.x, escaping [ inside []

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Won't Fix
    • PUP 4.1.0
    • None
    • Compiler
    • None
    • new version: OracleLinux 7.1, x86_64, puppetserver-1.0.8-1.el7.noarch
      vs old version: OracleLinux 6.5, x86_64, puppet-server-3.7.5-1.el6.noarch

    Description

      While evaluating new puppet server 4.x as a replacement of 3.x we found the following incompatibility.

      In version 3.x (and all versions before) this expression worked fine:

      $safe_regex_value = regsubst($value, '[.[$()|*+?{\^]', '\\\0', 'G')
      

      and stopped working on a new version (even catalog compilation fails):

      Error: Could not retrieve catalog from remote server: Error 400 on SERVER: regsubst(): Bad regular expression `[.[$()|*+?{\^]' at /etc/puppet/environments/development/modules/utils/manifests/set_option_in_file.pp:31 on node somenode.somedomain
      Warning: Not using cache on failed catalog
      Error: Could not retrieve catalog; skipping run
      

      It works only if we escape [ inside [] like:

      $safe_regex_value = regsubst($value, '[.\[$()|*+?{\^]', '\\\0', 'G')
      

      According to regexp docs , special characters between '[' and ']' doesn't have special meaning unless they are very first characters after '[', so this regexp '[[]' should be valid and should match single open square bracket. You may test this behavior with grep:

      echo '[' | grep '[[]'
      

      Attachments

        Activity

          People

            henrik.lindberg Henrik Lindberg
            Nopius Artyom A. Konovalenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support