Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
Night's Watch
-
1
-
NW - 2021-09-08
-
Needs Assessment
-
Bug Fix
-
This fix removes BOM for non-UTF encoding and its warnings. Since ASCII characters are single bytes, there is no need for a BOM to detect byte ordering (LSB/MSB).
-
Needs Assessment
Description
The fix for PUP-8243 causes ruby to generate a warning if the default external encoding is US-ASCII:
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/file_system/file_impl.rb:83: warning: BOM with non-UTF encoding US-ASCII is nonsense
|
Since ASCII characters are single bytes, there is no need for a BOM to detect byte ordering (LSB/MSB), hence the message. I had assumed ruby would just ignore the `bom` prefix.
We'll need to check that the current external encoding starts with `utf-` (case-insensitively I think), and only add the `bom` prefix if it does.
See https://github.com/puppetlabs/puppet/pull/8639#issuecomment-891939114
To reproduce:
$ bx ruby -e 'Encoding.default_external = "US-ASCII"; require "puppet"; Puppet::FileSystem.read_preserve_line_endings("Gemfile")'
|
/home/josh/work/puppet/lib/puppet/file_system/file_impl.rb:83: warning: BOM with non-UTF encoding US-ASCII is nonsense
|