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

Unicode characters in 'comment' don't round-trip on Windows

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.9.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide

      Puppet can round-trip unicode characters in the Description field on Windows.

      Show
      Puppet can round-trip unicode characters in the Description field on Windows.
    • Team:
      Agent
    • Story Points:
      2
    • Sprint:
      AP 2017-01-11
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Prior to Puppet 4.9.0, if a puppet agent was run in a non-UTF-8 locale, puppet would fail to apply a change to a user comment on linux and Windows if the change included UTF-8 comments. This has been resolved in Puppet 4.9.0.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      Well-tested in spec

      Description

      Given `puppet apply` this manifest:

        user { 'foo' :
          comment => "\u2603",
          ensure => present,
        }
      

      The following change happens on every puppet run:

      Notice: /Stage[main]/Main/User[foo]/comment: comment changed '?' to '☃'
      

      Different unicode characters have the same result:

      ...
      comment => "\u{2070E}"
      ...
      

      results in:

      Notice: /Stage[main]/Main/User[foo]/comment: comment changed '??' to '𠜎'
      

      A quick investigation makes it appear we're failing to correctly round-trip the unicode to/from Windows in https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/adsi.rb#L197-L206:

      From: C:/Users/moses/development/puppet/lib/puppet/util/windows/adsi.rb @ line 207 Puppet::Util::Windows::ADSI::User#[]=:
       
          205: def []=(attribute, value)
          206:   require 'pry';binding.pry
       => 207:   native_user.Put(attribute, value)
          208: end
       
      [18] pry(#<Puppet::Util::Windows::ADSI::User>)> attribute
      => "Description"
      [19] pry(#<Puppet::Util::Windows::ADSI::User>)> value
      => "\u{2070E}"
      [20] pry(#<Puppet::Util::Windows::ADSI::User>)> value.bytes
      => [240, 160, 156, 142]
      [21] pry(#<Puppet::Util::Windows::ADSI::User>)> native_user.Put(attribute, value)
      => nil
      [22] pry(#<Puppet::Util::Windows::ADSI::User>)> is = native_user.Get(attribute)
      => "??"
      [23] pry(#<Puppet::Util::Windows::ADSI::User>)> is.bytes
      => [63, 63]
      [24] pry(#<Puppet::Util::Windows::ADSI::User>)> Encoding.default_external
      => #<Encoding:IBM437>
      [25] pry(#<Puppet::Util::Windows::ADSI::User>)> value.encoding
      => #<Encoding:UTF-8>
      [26] pry(#<Puppet::Util::Windows::ADSI::User>)> is.encoding
      => #<Encoding:IBM437>
      

      Note that the bytes read back via `Get` are not the same as the value we `Put`

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support