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

Stray UTF-8 character in manifest corrupts parsed parameters

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: PUP 4.3.2
    • Fix Version/s: PUP 4.4.0
    • Component/s: None
    • Labels:
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      A regression was found where UTF-8 multibyte characters in a manifest would cause problems in services extracting selected parts of the source code. Node Classifier would present truncated/misaligned source snippets for default value expressions in the UI, and Puppet String would present garbage in generated documentation, or in worst case crash.
      Show
      A regression was found where UTF-8 multibyte characters in a manifest would cause problems in services extracting selected parts of the source code. Node Classifier would present truncated/misaligned source snippets for default value expressions in the UI, and Puppet String would present garbage in generated documentation, or in worst case crash.

      Description

      If I have the Puppet::InfoService::ClassInformationService or resource_types endpoint parse a manifest which includes a special UTF-8 character, the resulting default values parsed for parameters appear to be corrupted.

      Here is the manifest file I used for this test, also attached as "parse.pp":

      class myclass (
         String $a_string = "this is a Ѐ string",
         Integer $an_integer = 3,
      ) {}
      

      Note that the character at the end of the comment line is a Cyrillic Capital letter Ye with grave, Unicode code point of U+0400, hex representation of 0xD080 in UTF-8 in the file.

      Running the following code...

      require 'puppet'
      require 'puppet/info_service'
       
      files_to_parse = { "production" => [ "./parse.pp" ] }
       
      puts Puppet::InfoService::ClassInformationService.new.classes_per_environment(files_to_parse)
      

      ... produces the following output:

      {"production"=>{"./parse.pp"=>{:classes=>[{:name=>"myclass", :params=>[{:name=>"a_string", :type=>"String", :default_literal=>"this is a Ѐ string", :default_source=>"\"this is a Ѐ string\","}, {:name=>"an_integer", :type=>"Integer", :default_literal=>3, :default_source=>","}]}]}}}
      

      The `:default_literal` values for each parameter appear to be correct but the `:default_source` values do not. Instead of "\"this is a Ѐ string\",", I would have expected "\"this is a Ѐ string\"". Instead of ",", I would have expected "3".

      This problem does not appear to be unique to the ClassInformationService. I get the same error when I use the "resource_types" endpoint to query for this data. For a query to "https://localhost:8140/puppet/v3/resource_types/*?kind=class&environment=production" where the "parse.pp" file is stored under the "<code-dir>/environments/production/modules/mymodule/manifests" directory, I get the following response (pretty-printed for display):

      [
          {
              "kind": "class",
              "line": 2,
              "name": "myclass",
              "parameters": {
                  "a_string": "\"this is a Ѐ string\",",
                  "an_integer": ","
              }
          }
      ]
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  jeremy.barlow Jeremy Barlow
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: