@@ -158,52 +158,6 @@ def withenv_utf8(&block)
158
158
expect ( process . get_environment_strings [ utf_8_key ] ) . to eq ( nil )
159
159
end
160
160
161
- # document buggy Ruby behavior here for https://bugs.ruby-lang.org/issues/8822
162
- # Ruby retrieves / stores ENV names in the current codepage
163
- # when these tests no longer pass, Ruby has fixed its bugs and workarounds can be removed
164
-
165
- # In 2.3, the behavior is mostly correct when external codepage is 65001 / UTF-8
166
- it "works around Ruby bug 8822 (which fails to preserve UTF-8 properly when accessing ENV) (Ruby >= 2.3.x) " ,
167
- :if => Puppet ::Util ::Platform . windows? && RUBY_VERSION . to_f < 3 do
168
-
169
- withenv_utf8 do |utf_8_key , utf_8_value , codepage_key |
170
- # Ruby 2.3 fixes access by the original UTF-8 key, and behaves differently than 2.1
171
- # keying by local codepage will work only when the UTF-8 can be converted to local codepage
172
- # the key selected for this test contains characters unavailable to a local codepage, hence doesn't work
173
-
174
- # On Japanese Windows (Code Page 932) this test resolves as true.
175
- # otherwise the key selected for this test contains characters
176
- # unavailable to a local codepage, hence doesn't work
177
- # HACK: tech debt to replace once PUP-7019 is understood
178
- should_be_found = ( Encoding . default_external == Encoding ::CP932 )
179
- expect ( ENV . key? ( codepage_key ) ) . to eq ( should_be_found )
180
- expect ( ENV . key? ( utf_8_key ) ) . to eq ( true )
181
-
182
- # Ruby's ENV.keys has slightly different behavior than ENV.key?(key), and 2.3 differs from 2.1
183
- # (codepage_key / utf_8_key have same bytes for the sake of searching)
184
- found = ENV . keys . find { |k | k . bytes == codepage_key . bytes }
185
-
186
- # the keys collection in 2.3 does not have a string with the correct bytes!
187
- # a corrupt version of the key exists with the bytes [225, 154, 160] replaced with [63]!
188
- expect ( found ) . to be_nil
189
-
190
- # given the key is corrupted, include? cannot be used to find it in either UTF-8 or codepage encoding
191
- expect ( ENV . keys . include? ( codepage_key ) ) . to eq ( false )
192
- expect ( ENV . keys . include? ( utf_8_key ) ) . to eq ( false )
193
-
194
- # The value stored at the UTF-8 key is a corrupted current codepage string and won't match UTF-8 value
195
- # again the bytes [225, 154, 160] have irreversibly been changed to [63]!
196
- env_value = ENV [ utf_8_key ]
197
- expect ( env_value ) . to_not eq ( utf_8_value )
198
- expect ( env_value . encoding ) . to_not eq ( Encoding ::UTF_8 )
199
-
200
- # the ENV value returned will be in the local codepage which may or may not be able to be
201
- # encoded to UTF8. Our test UTF8 data is not convertible to non-Unicode codepages
202
- converted_value = ENV [ utf_8_key ] . dup . force_encoding ( Encoding ::UTF_8 )
203
- expect ( converted_value ) . to_not eq ( utf_8_value )
204
- end
205
- end
206
-
207
161
it "should preseve existing environment and should not corrupt UTF-8 environment variables" do
208
162
env_var_name = SecureRandom . uuid
209
163
utf_8_bytes = [ 225 , 154 , 160 ] # rune ᚠ
0 commit comments