mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-04 22:59:47 +00:00
do not replace all invalid utf8 (#24616)
git-svn-id: http://svn.redmine.org/redmine/trunk@16273 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
281bc5c454
commit
b2c0ea2c3e
@ -6,7 +6,7 @@ module Redmine
|
||||
return str if str.nil?
|
||||
str.force_encoding('UTF-8')
|
||||
if ! str.valid_encoding?
|
||||
str = str.encode("US-ASCII", :invalid => :replace,
|
||||
str = str.encode("UTF-16LE", :invalid => :replace,
|
||||
:undef => :replace, :replace => '?').encode("UTF-8")
|
||||
end
|
||||
str
|
||||
|
||||
@ -91,7 +91,7 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase
|
||||
s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1)
|
||||
assert s2.valid_encoding?
|
||||
assert_equal "UTF-8", s2.encoding.to_s
|
||||
assert_equal "??????", s2
|
||||
assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1??".force_encoding("UTF-8"), s2
|
||||
end
|
||||
|
||||
test "#to_utf8 should replace invalid non utf8" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user