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

Lexer should raise a better error when loading manifest files containing a UTF-8 BOM (Byte Order Mark)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: None
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Puppet will now raise an error if a puppet language source file starts with a Byte Order Mark. The error identifies the name of the Byte Order Mark, and shows the bytes in hex that should be removed. Earlier such marks caused a SyntaxError to be issued and it was hard to understand the cause.
      Puppet always uses UTF-8, and forbids Byte Order Marks to be present in source files.
      Show
      Puppet will now raise an error if a puppet language source file starts with a Byte Order Mark. The error identifies the name of the Byte Order Mark, and shows the bytes in hex that should be removed. Earlier such marks caused a SyntaxError to be issued and it was hard to understand the cause. Puppet always uses UTF-8, and forbids Byte Order Marks to be present in source files.

      Description

      The current error message that Puppet propagates when lexing files that contain a leading UTF-8 BOM (0xFEFF) is Syntax error at '' at line 1:1.

      Saving a file with a UTF-8 BOM is rather common on Windows, and Puppet should be able to report a better error during the parsing phase that helps inform users of the appropriate action to take, given the parser cannot handle a BOM. spec/unit/face/parser_spec.rb currently contains a test documenting the current behavior as part of https://github.com/puppetlabs/puppet/pull/4585/files

      Note - this does not impact loading of Ruby code from puppet modules. Such loading uses the Ruby eval method after reading files from disk, and even if the content contains a leading BOM, Ruby does not have a problem parsing / executing the code.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ethan Ethan Brown
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support