Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PUP-11841) Fix encoding of empty String #9102

Merged
merged 1 commit into from
Sep 12, 2023

Commits on Aug 21, 2023

  1. (PUP-11841) Fix encoding of empty String

    In 2077971 empty string literals where
    replaced by a call to `String.new` in preparation for moving to
    frozen/immutable strings.
    
    However, as stated in the String#new documentation, when no value is
    passed to `#new` the returned string has the 'ASCII-8BIT' encoding
    instead of the default one (which is assumed to be 'UTF-8' by Puppet).
    
    This cause regressions in some areas of the code, for example when using
    the concat module with exported resource built using epp templates, the
    incorrect encoding cause the fragment to be misinterpreted and is base64
    encoded.  When collected, the base64 representation of the string is
    used instead of the actual value of the string, as reported here:
    voxpupuli/puppet-bacula#189
    
    Replace calls to `String.new` with `''.dup` which use the current
    encoding.  Do not change the few explicit but redundant occurrences of
    `String.new.force_encoding('ASCII-8BIT')` (so that the intent is clearly
    visible).  Where appropriate, slightly adjust the code for better
    readability.
    smortex committed Aug 21, 2023
    Configuration menu
    Copy the full SHA
    fb20023 View commit details
    Browse the repository at this point in the history