Patch #44734 ยป 0001-Use-String-scrub-to-replace-invalid-UTF-8-byte-seque.patch
| lib/redmine/codeset_util.rb | ||
|---|---|---|
| 22 | 22 |
def self.replace_invalid_utf8(str) |
| 23 | 23 |
return nil if str.nil? |
| 24 | 24 | |
| 25 |
str = str.dup |
|
| 26 |
str.force_encoding('UTF-8')
|
|
| 27 |
unless str.valid_encoding? |
|
| 28 |
str = str.encode("UTF-16LE", :invalid => :replace,
|
|
| 29 |
:undef => :replace, :replace => '?').encode("UTF-8")
|
|
| 30 |
end |
|
| 31 |
str |
|
| 25 |
str.dup.force_encoding('UTF-8').scrub('?')
|
|
| 32 | 26 |
end |
| 33 | 27 | |
| 34 | 28 |
def self.to_utf8(str, encoding) |