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

ERB and EPP templates handle CRLF line endings inconsistently

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.10.9, PUP 5.3.3
    • Fix Version/s: PUP 5.5.1
    • Component/s: None
    • Labels:
      None
    • Template:
      PUP Bug Template
    • Acceptance Criteria:
      Hide

      ERB and EPP templates invoked with content or source attributes in a manifest, and pointing to templates that contain CRLF line endings or \r\n, should consistently generate files containing CRLF line breaks.

      Show
      ERB and EPP templates invoked with content or source attributes in a manifest, and pointing to templates that contain CRLF line endings or \r\n , should consistently generate files containing CRLF line breaks.
    • Team:
      Platform Core
    • Method Found:
      Customer Feedback
    • CS Priority:
      Major
    • CS Frequency:
      3 - 25-50% of Customers
    • CS Severity:
      3 - Serious
    • CS Business Value:
      5 - $$$$$$
    • CS Impact:
      This bug makes it extremely difficult or impossible for customers to use templates to create files for windows systems with the correct CRLF line endings.
    • Release Notes:
      Known Issue
    • Release Notes Summary:
      EPP templates containing CRLF line breaks did not generate files containing CRLF line breaks, which is the expected result and also the result when using CRLF line breaks in ERB templates. This is now corrected.
    • QA Risk Assessment:
      Needs Assessment

      Description

      Via Geoff Williams on DOCUMENT-779:

      expected result

      When applying a puppet manifest and its EPP template using CRLF line endings to generate a file, the generated file should also use CRLF line endings.

      When using a CRLF escape sequence in ERB or EPP templates (\r\n), Puppet should replace the sequence with a CRLF line ending in the generated file.

      This is documented at Handling line endings on Resource tips and Examples: File on Windows:

      • If a file resource uses the content or source attributes, Puppet will write the file in “binary” mode, using whatever line endings are present in the content.
        • If the manifest, template, or source file is saved with CRLF line endings, Puppet will use those endings in the destination file.
        • If the manifest, template, or source file is saved with LF line endings, you can use the \r\n escape sequence to create literal CRLFs.

      actual result

      Following the instructions produces one long line of text instead of text with CRLF line breaks, and \r\n appears literally in the output instead of being replaced with a CRLF line break.

      test case

      test.pp:

      file { "c:/test.txt":
        content => epp("c:/test.epp")
      }
      

      test.epp:

      line 1
      line 2
      :P
      

      test.txt (result)

      line 1line 2:P
      

      Files were created in notepad to get the line endings. See the attachment.

      Escape codes in the template:

      test.epp:

      line 1\r\n
      line 2\r\n
      :P\r\n
      

      test.txt output:

      line 1\r\nline 2\r\n:P\r\n
      

      How to run testcase (save to c:):

      puppet apply c:\test.pp
      

      workaround
      Traditional erb templates' template() handle CRLF line endings as documented and expected, although these also result in literal \r\n in the output, which still conflicts with the documentation.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                williams.geoff Geoff Williams
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support