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

new function (String): programmatic representation escapes for Ruby language and not Puppet

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.5.0
    • Fix Version/s: PUP 4.5.3
    • Component/s: None
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide
      • All strings containing backslash, dollar, single quote, double quote, non printable ascii (control chars), or chars outside of the ascii range are converted to double quoted strings with escapes for special characters.
      • All other (simple ascii) strings are single quoted
      • All string conversion is done such that if the produced text is read again by puppet, the result is the same string as the original converted string.
      Show
      All strings containing backslash, dollar, single quote, double quote, non printable ascii (control chars), or chars outside of the ascii range are converted to double quoted strings with escapes for special characters. All other (simple ascii) strings are single quoted All string conversion is done such that if the produced text is read again by puppet, the result is the same string as the original converted string.
    • Story Points:
      2
    • Sprint:
      Language 2016-07-13
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Conversion to String using the `new` function and the programmatic `%p` option used Ruby escape conventions instead of Puppet. This is now corrected. Simple strings containing ascii range non control chars will be single quoted, and all other strings double quoted with special characters escaped and non ascii range characters using `\u` (unicode) notation.
      Show
      Conversion to String using the `new` function and the programmatic `%p` option used Ruby escape conventions instead of Puppet. This is now corrected. Simple strings containing ascii range non control chars will be single quoted, and all other strings double quoted with special characters escaped and non ascii range characters using `\u` (unicode) notation.

      Description

      Conversions to String using the new function with the %p format escapes characters for the Ruby language and not the Puppet language.

      notice String('foo#{bar}', '%p')
      notice String("\u{1b}", '%p')
      notice String('$foobar', '%p')
      

      Outputs:

      Notice: Scope(Class[main]): "foo\#{bar}"
      Notice: Scope(Class[main]): "\e"
      Notice: Scope(Class[main]): "$foobar"
      

      Expected output:

      Notice: Scope(Class[main]): "foo#{bar}"
      Notice: Scope(Class[main]): "\u{1b}"
      Notice: Scope(Class[main]): "\$foobar"
      

      In the first example, #{...} should not be escaped as has no semantic meaning in Puppet.

      In the second example, \e is not a valid escape character in Puppet. We should probably be outputting \u{...} for ASCII control characters that do not already have an escape representation in Puppet.

      In the third example, $ needs to be escaped as it starts interpolation in Puppet (like #{...} would need to be in Ruby).

      This is a result of using Kernel#format to output the programmatic representation; there needs to be an implementation that conforms to Puppet strings and not Ruby strings.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  peter.huene Peter Huene
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: