Skip to content

Commit f4e4d32

Browse files
committed
Fix double transcoding of XML-escaped characters in String#{encode,encode!}.
1 parent 04a9c36 commit f4e4d32

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Bug fixes:
44

55
* Fixed a bug with `String#lines` and similar methods with multibyte
66
characters (#1543).
7+
* Fixed an issue with `String#{encode,encode!}` double-processing strings
8+
using XML conversion options and a new destination encoding (#1545).
79

810
Compatibility:
911

spec/tags/core/string/encode_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/ruby/core/string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
# Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. This
3+
# Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. This
44
# code is released under a tri EPL/GPL/LGPL license. You can use it,
55
# redistribute it and/or modify it under the terms of the:
66
#
@@ -454,7 +454,7 @@ def encode!(to=undefined, from=undefined, options=undefined)
454454
dest = +''
455455
status = ec.primitive_convert self.dup, dest, nil, nil, ec.options
456456
raise ec.last_error unless status == :finished
457-
replace dest
457+
return replace(dest)
458458
elsif options == 0
459459
force_encoding to_enc
460460
end

0 commit comments

Comments
 (0)