Patch #31004 » 31004-hexadecimal-encoded-to-frozen-string.patch
| test/functional/attachments_controller_test.rb | ||
|---|---|---|
|
assert a.save
|
||
|
assert_equal 'japanese-utf-8.txt', a.filename
|
||
|
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
get :show, :params => {
|
||
|
:id => a.id
|
||
|
}
|
||
| ... | ... | |
|
assert_equal 'text/html', @response.content_type
|
||
|
assert_select 'tr#L1' do
|
||
|
assert_select 'th.line-num', :text => '1'
|
||
|
assert_select 'td', :text => /#{str_japanese}/
|
||
|
assert_select 'td', :text => /日本語/
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
'1' => {
|
||
|
:filename => 'newname.text',
|
||
|
:description => ''
|
||
|
},
|
||
|
},
|
||
|
'4' => {
|
||
|
:filename => 'newname.rb',
|
||
|
:description => 'Renamed'
|
||
|
},
|
||
|
|
||
|
},
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
'1' => {
|
||
|
:filename => '',
|
||
|
:description => ''
|
||
|
},
|
||
|
},
|
||
|
'4' => {
|
||
|
:filename => 'newname.rb',
|
||
|
:description => 'Renamed'
|
||
|
},
|
||
|
|
||
|
},
|
||
|
}
|
||
|
}
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
def test_index_csv_big_5
|
||
|
with_settings :default_language => "zh-TW" do
|
||
|
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
|
||
|
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||
|
str_utf8 = '一月'
|
||
|
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5')
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :params => {
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
header = lines[0]
|
||
|
status = "\xaa\xac\xbaA".force_encoding('Big5')
|
||
|
status = (+"\xaa\xac\xbaA").force_encoding('Big5')
|
||
|
assert_include status, header
|
||
|
issue_line = lines.find {|l| l =~ /^#{issue.id},/}
|
||
|
assert_include str_big5, issue_line
|
||
| ... | ... | |
|
def test_index_csv_cannot_convert_should_be_replaced_big_5
|
||
|
with_settings :default_language => "zh-TW" do
|
||
|
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||
|
str_utf8 = '以内'
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :params => {
|
||
| ... | ... | |
|
lines = @response.body.chomp.split("\n")
|
||
|
header = lines[0]
|
||
|
issue_line = lines.find {|l| l =~ /^#{issue.id},/}
|
||
|
s1 = "\xaa\xac\xbaA".force_encoding('Big5') # status
|
||
|
s1 = (+"\xaa\xac\xbaA").force_encoding('Big5') # status
|
||
|
assert header.include?(s1)
|
||
|
s2 = issue_line.split(",")[2]
|
||
|
s3 = "\xa5H?".force_encoding('Big5') # subject
|
||
|
s3 = (+"\xa5H?").force_encoding('Big5') # subject
|
||
|
assert_equal s3, s2
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
def test_export_to_pdf_with_utf8_u_fffd
|
||
|
# U+FFFD
|
||
|
s = "\xef\xbf\xbd"
|
||
|
s.force_encoding('UTF-8') if s.respond_to?(:force_encoding)
|
||
|
issue = Issue.generate!(:subject => s)
|
||
|
issue = Issue.generate!(:subject => "�")
|
||
|
["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
|
||
|
with_settings :default_language => lang do
|
||
|
get :show, :params => {
|
||
| test/functional/repositories_bazaar_controller_test.rb | ||
|---|---|---|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
|
||
|
REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
|
||
|
PRJ_ID = 3
|
||
|
CHAR_1_UTF8_HEX = "\xc3\x9c".dup.force_encoding('UTF-8')
|
||
|
def setup
|
||
|
super
|
||
| ... | ... | |
|
assert_select "th.line-num", :text => '1' do
|
||
|
assert_select "+ td.revision" do
|
||
|
assert_select "a", :text => '2'
|
||
|
assert_select "+ td.author", :text => "test #{CHAR_1_UTF8_HEX}" do
|
||
|
assert_select "+ td.author", :text => "test Ü" do
|
||
|
assert_select "+ td",
|
||
|
:text => "author non ASCII test"
|
||
|
end
|
||
| test/functional/repositories_filesystem_controller_test.rb | ||
|---|---|---|
|
"when Encoding.default_external is not UTF-8. " +
|
||
|
"Current value is '#{Encoding.default_external.to_s}'"
|
||
|
else
|
||
|
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/
|
||
|
assert_select 'tr#L3 td.line-code', :text => /日本語/
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/functional/repositories_git_controller_test.rb | ||
|---|---|---|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||
|
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||
|
PRJ_ID = 3
|
||
|
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||
|
FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8')
|
||
|
NUM_REV = 28
|
||
|
## Git, Mercurial and CVS path encodings are binary.
|
||
| ... | ... | |
|
:is_default => '0',
|
||
|
:identifier => 'test-create',
|
||
|
:report_last_commit => '1',
|
||
|
|
||
|
}
|
||
|
}
|
||
|
end
|
||
| ... | ... | |
|
:id => repository.id,
|
||
|
:repository => {
|
||
|
:report_last_commit => '0'
|
||
|
|
||
|
}
|
||
|
}
|
||
|
assert_response 302
|
||
| ... | ... | |
|
get :entry, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'table' do
|
||
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
|
||
|
assert_select 'tbody td.diff_in', :text => /test-#{CHAR_1_HEX}.txt/
|
||
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü.txt/
|
||
|
assert_select 'tbody td.diff_in', :text => /test-Ü.txt/
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
get :annotate, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_select "th.line-num", :text => '1' do
|
||
| ... | ... | |
|
assert_select "a", :text => '57ca437c'
|
||
|
assert_select "+ td.author", :text => "jsmith" do
|
||
|
assert_select "+ td",
|
||
|
:text => "test-#{CHAR_1_HEX}.txt"
|
||
|
:text => "test-Ü.txt"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
assert_select "th.line-num", :text => '1' do
|
||
|
assert_select "+ td.revision" do
|
||
|
assert_select "a", :text => '83ca5fd5'
|
||
|
assert_select "+ td.author", :text => FELIX_HEX do
|
||
|
assert_select "+ td.author", :text => "Felix Schäfer" do
|
||
|
assert_select "+ td",
|
||
|
:text => "And this is a file with a leading and trailing space..."
|
||
|
end
|
||
| test/functional/repositories_mercurial_controller_test.rb | ||
|---|---|---|
|
:repositories, :enabled_modules
|
||
|
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
|
||
|
CHAR_1_HEX = "\xc3\x9c"
|
||
|
PRJ_ID = 3
|
||
|
NUM_REV = 34
|
||
| ... | ... | |
|
)
|
||
|
assert @repository
|
||
|
@diff_c_support = true
|
||
|
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8')
|
||
|
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||
|
end
|
||
|
if ruby19_non_utf8_pass
|
||
| ... | ... | |
|
assert_select 'table.entries tbody' do
|
||
|
assert_select 'tr', 4
|
||
|
assert_select 'tr.file td.filename a', :text => "make-latin-1-file.rb"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-1.txt"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-2.txt"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}.txt"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-Ü-1.txt"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-Ü-2.txt"
|
||
|
assert_select 'tr.file td.filename a', :text => "test-Ü.txt"
|
||
|
end
|
||
|
assert_select 'table.changesets tbody' do
|
||
| ... | ... | |
|
assert_equal NUM_REV, @repository.changesets.count
|
||
|
[
|
||
|
'default',
|
||
|
@branch_char_1,
|
||
|
'branch-Ü-01',
|
||
|
'branch (1)[2]&,%.-3_4',
|
||
|
@branch_char_0,
|
||
|
'branch-Ü-00',
|
||
|
'test_branch.latin-1',
|
||
|
'test-branch-00',
|
||
|
].each do |bra|
|
||
| ... | ... | |
|
@project.reload
|
||
|
assert_equal NUM_REV, @repository.changesets.count
|
||
|
[
|
||
|
@tag_char_1,
|
||
|
'tag-Ü-00',
|
||
|
'tag_test.00',
|
||
|
'tag-init-revision'
|
||
|
].each do |tag|
|
||
| ... | ... | |
|
get :entry, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_response :success
|
||
| ... | ... | |
|
get :entry, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'table' do
|
||
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
|
||
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü-2.txt/
|
||
|
assert_select 'tbody td.diff_in', :text => /It is written in Python/
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
get :annotate, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_response :success
|
||
| ... | ... | |
|
get :annotate, :params => {
|
||
|
:id => PRJ_ID,
|
||
|
:repository_id => @repository.id,
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
||
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
||
|
:rev => r1
|
||
|
}
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
|
||
|
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/functional/timelog_report_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_csv_big_5
|
||
|
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
|
||
|
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||
|
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5')
|
||
|
user = User.find_by_id(3)
|
||
|
user.firstname = str_utf8
|
||
|
user.firstname = "一月"
|
||
|
user.lastname = "test-lastname"
|
||
|
assert user.save
|
||
|
comments = "test_csv_big_5"
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s2 = "\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
s2 = (+"\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1]
|
||
|
assert_equal "#{s2},7.30,7.30", lines[2]
|
||
|
str_tw = "Chinese/Traditional (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)".force_encoding('UTF-8')
|
||
|
assert_equal str_tw, l(:general_lang_name)
|
||
|
assert_equal 'Chinese/Traditional (繁體中文)', l(:general_lang_name)
|
||
|
assert_equal 'Big5', l(:general_csv_encoding)
|
||
|
assert_equal ',', l(:general_csv_separator)
|
||
|
assert_equal '.', l(:general_csv_decimal_separator)
|
||
|
end
|
||
|
def test_csv_cannot_convert_should_be_replaced_big_5
|
||
|
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||
|
user = User.find_by_id(3)
|
||
|
user.firstname = str_utf8
|
||
|
user.firstname = "以内"
|
||
|
user.lastname = "test-lastname"
|
||
|
assert user.save
|
||
|
comments = "test_replaced"
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
s2 = "\xa5H?".force_encoding('Big5')
|
||
|
s2 = (+"\xa5H?").force_encoding('Big5')
|
||
|
assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
|
||
|
end
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "Utilisateur;2011-11-11;Temps total".force_encoding('ISO-8859-1')
|
||
|
s2 = "Temps total".force_encoding('ISO-8859-1')
|
||
|
s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1')
|
||
|
s2 = (+"Temps total").force_encoding('ISO-8859-1')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1]
|
||
|
assert_equal "#{s2};7,30;7,30", lines[2]
|
||
|
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8')
|
||
|
assert_equal str_fr, l(:general_lang_name)
|
||
|
assert_equal 'French (Français)', l(:general_lang_name)
|
||
|
assert_equal 'ISO-8859-1', l(:general_csv_encoding)
|
||
|
assert_equal ';', l(:general_csv_separator)
|
||
|
assert_equal ',', l(:general_csv_decimal_separator)
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
def setup
|
||
|
super
|
||
|
set_tmp_attachments_directory
|
||
|
@russian_test = "\xd1\x82\xd0\xb5\xd1\x81\xd1\x82".force_encoding('UTF-8')
|
||
|
@russian_test = 'тест'
|
||
|
end
|
||
|
test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" do
|
||
| ... | ... | |
|
end
|
||
|
def test_truncate_single_line_non_ascii
|
||
|
ja = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
ja = '日本語'
|
||
|
result = truncate_single_line_raw("#{ja}\n#{ja}\n#{ja}", 10)
|
||
|
assert_equal "#{ja} #{ja}...", result
|
||
|
assert !result.html_safe?
|
||
| test/integration/api_test/authentication_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_invalid_utf8_credentials_should_not_trigger_an_error
|
||
|
invalid_utf8 = "\x82".force_encoding('UTF-8')
|
||
|
invalid_utf8 = "\x82"
|
||
|
assert !invalid_utf8.valid_encoding?
|
||
|
assert_nothing_raised do
|
||
|
get '/users/current.xml', :headers => credentials(invalid_utf8, "foo")
|
||
| test/unit/attachment_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_latest_attach_should_not_error_with_string_with_invalid_encoding
|
||
|
string = "width:50\xFE-Image.jpg".force_encoding('UTF-8')
|
||
|
string = "width:50\xFE-Image.jpg"
|
||
|
assert_equal false, string.valid_encoding?
|
||
|
Attachment.latest_attach(Attachment.limit(2).to_a, string)
|
||
| test/unit/changeset_test.rb | ||
|---|---|---|
|
def test_comments_should_be_converted_to_utf8
|
||
|
proj = Project.find(3)
|
||
|
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
||
|
str = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT")
|
||
|
str = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
:scmid => '12345',
|
||
|
:comments => str)
|
||
|
assert( c.save )
|
||
|
str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8")
|
||
|
assert_equal str_utf8, c.comments
|
||
|
assert_equal 'Texte encodé en ISO-8859-1.', c.comments
|
||
|
end
|
||
|
def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1
|
||
|
proj = Project.find(3)
|
||
|
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
:committed_on => Time.now,
|
||
|
:revision => '123',
|
||
|
:scmid => '12345',
|
||
|
:comments => str1,
|
||
|
:comments => "Texte encod\xE9 en ISO-8859-1.",
|
||
|
:committer => str2)
|
||
|
assert( c.save )
|
||
|
assert_equal "Texte encod? en ISO-8859-1.", c.comments
|
||
| ... | ... | |
|
def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
|
||
|
proj = Project.find(3)
|
||
|
str = "test\xb5\xfetest\xb5\xfe".force_encoding('ASCII-8BIT')
|
||
|
str = (+"test\xb5\xfetest\xb5\xfe").force_encoding('ASCII-8BIT')
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
end
|
||
|
def test_comments_should_be_converted_all_latin1_to_utf8
|
||
|
s1 = "\xC2\x80"
|
||
|
s2 = "\xc3\x82\xc2\x80"
|
||
|
s1 = +"\xC2\x80"
|
||
|
s2 = +"\xc3\x82\xc2\x80"
|
||
|
s4 = s2.dup
|
||
|
s3 = s1.dup
|
||
|
s1.force_encoding('ASCII-8BIT')
|
||
| ... | ... | |
|
def test_invalid_utf8_sequences_in_paths_should_be_replaced
|
||
|
proj = Project.find(3)
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
ch = Change.new(
|
||
|
:changeset => cs,
|
||
|
:action => "A",
|
||
|
:path => str1,
|
||
|
:path => "Texte encod\xE9 en ISO-8859-1",
|
||
|
:from_path => str2,
|
||
|
:from_revision => "345")
|
||
|
assert(ch.save)
|
||
| test/unit/custom_field_test.rb | ||
|---|---|---|
|
def test_possible_values_should_return_utf8_encoded_strings
|
||
|
field = CustomField.new
|
||
|
s = "Value".force_encoding('BINARY')
|
||
|
s = (+"Value").force_encoding('BINARY')
|
||
|
field.possible_values = s
|
||
|
assert_equal [s], field.possible_values
|
||
|
assert_equal 'UTF-8', field.possible_values.first.encoding.name
|
||
| test/unit/group_test.rb | ||
|---|---|---|
|
def test_blank_name_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
g = Group.new
|
||
|
assert !g.save
|
||
|
assert_include str, g.errors.full_messages
|
||
|
assert_include 'Nom doit être renseigné(e)', g.errors.full_messages
|
||
|
end
|
||
|
def test_group_roles_should_be_given_to_added_user
|
||
| test/unit/lib/redmine/codeset_util_test.rb | ||
|---|---|---|
|
def test_to_utf8_by_setting_from_latin1
|
||
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||
|
s1 = "Texte encod\xc3\xa9".force_encoding("UTF-8")
|
||
|
s2 = "Texte encod\xe9".force_encoding("ASCII-8BIT")
|
||
|
s1 = 'Texte encodé'
|
||
|
s2 = (+"Texte encod\xe9").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_from_euc_jp
|
||
|
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
|
||
|
s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3".force_encoding("UTF-8")
|
||
|
s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3".force_encoding("ASCII-8BIT")
|
||
|
s1 = 'レッドマイン'
|
||
|
s2 = (+"\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_should_be_converted_all_latin1
|
||
|
with_settings :repositories_encodings => 'ISO-8859-1' do
|
||
|
s1 = "\xc3\x82\xc2\x80".force_encoding("UTF-8")
|
||
|
s2 = "\xC2\x80".force_encoding("ASCII-8BIT")
|
||
|
s1 = "Â\u0080"
|
||
|
s2 = (+"\xC2\x80").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
end
|
||
|
def test_to_utf8_by_setting_returns_ascii_as_utf8
|
||
|
s1 = "ASCII".force_encoding("UTF-8")
|
||
|
s1 = 'ASCII'
|
||
|
s2 = s1.dup.force_encoding("ISO-8859-1")
|
||
|
str1 = Redmine::CodesetUtil.to_utf8_by_setting(s1)
|
||
|
str2 = Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
# s1 = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
||
|
s1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT")
|
||
|
s1 = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT")
|
||
|
str = Redmine::CodesetUtil.to_utf8_by_setting(s1)
|
||
|
assert str.valid_encoding?
|
||
|
assert_equal "UTF-8", str.encoding.to_s
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped_ja_jis
|
||
|
with_settings :repositories_encodings => 'ISO-2022-JP' do
|
||
|
s1 = "test\xb5\xfetest\xb5\xfe".force_encoding("ASCII-8BIT")
|
||
|
s1 = (+"test\xb5\xfetest\xb5\xfe").force_encoding("ASCII-8BIT")
|
||
|
str = Redmine::CodesetUtil.to_utf8_by_setting(s1)
|
||
|
assert str.valid_encoding?
|
||
|
assert_equal "UTF-8", str.encoding.to_s
|
||
| ... | ... | |
|
end
|
||
|
test "#replace_invalid_utf8 should replace invalid utf8" do
|
||
|
s1 = "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xE3\x81\xFF".force_encoding("UTF-8")
|
||
|
s1 = "こんにち\xE3\x81\xFF"
|
||
|
s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1)
|
||
|
assert s2.valid_encoding?
|
||
|
assert_equal "UTF-8", s2.encoding.to_s
|
||
|
assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1??".force_encoding("UTF-8"), s2
|
||
|
assert_equal 'こんにち??', s2
|
||
|
end
|
||
|
test "#to_utf8 should replace invalid non utf8" do
|
||
|
s1 = "\xa4\xb3\xa4\xf3\xa4\xcb\xa4\xc1\xa4".force_encoding("EUC-JP")
|
||
|
s1 = (+"\xa4\xb3\xa4\xf3\xa4\xcb\xa4\xc1\xa4").force_encoding("EUC-JP")
|
||
|
s2 = Redmine::CodesetUtil.to_utf8(s1, "EUC-JP")
|
||
|
assert s2.valid_encoding?
|
||
|
assert_equal "UTF-8", s2.encoding.to_s
|
||
|
assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1?".force_encoding("UTF-8"), s2
|
||
|
assert_equal 'こんにち?', s2
|
||
|
end
|
||
|
end
|
||
| test/unit/lib/redmine/export/csv_test.rb | ||
|---|---|---|
|
class CsvTest < ActiveSupport::TestCase
|
||
|
include Redmine::I18n
|
||
|
BOM = "\xEF\xBB\xBF".force_encoding('UTF-8')
|
||
|
def test_should_include_bom_when_utf8_encoded
|
||
|
with_locale 'sk' do
|
||
|
string = Redmine::Export::CSV.generate {|csv| csv << %w(Foo Bar)}
|
||
|
assert_equal 'UTF-8', string.encoding.name
|
||
|
assert string.starts_with?(BOM)
|
||
|
assert string.starts_with?("\xEF\xBB\xBF")
|
||
|
end
|
||
|
end
|
||
| test/unit/lib/redmine/export/pdf_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_rdm_pdf_iconv_cannot_convert_ja_cp932
|
||
|
utf8_txt_1 = "\xe7\x8b\x80\xe6\x85\x8b"
|
||
|
utf8_txt_2 = "\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80"
|
||
|
utf8_txt_3 = "\xe7\x8b\x80\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80"
|
||
|
utf8_txt_1 = '狀態'
|
||
|
utf8_txt_2 = '狀態狀'
|
||
|
utf8_txt_3 = '狀狀態狀'
|
||
|
["CP932", "SJIS"].each do |encoding|
|
||
|
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_1, encoding)
|
||
|
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_2, encoding)
|
||
|
txt_3 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_3, encoding)
|
||
|
assert_equal "?\x91\xd4".force_encoding("ASCII-8BIT"), txt_1
|
||
|
assert_equal "?\x91\xd4?".force_encoding("ASCII-8BIT"), txt_2
|
||
|
assert_equal "??\x91\xd4?".force_encoding("ASCII-8BIT"), txt_3
|
||
|
assert_equal (+"?\x91\xd4").force_encoding("ASCII-8BIT"), txt_1
|
||
|
assert_equal (+"?\x91\xd4?").force_encoding("ASCII-8BIT"), txt_2
|
||
|
assert_equal (+"??\x91\xd4?").force_encoding("ASCII-8BIT"), txt_3
|
||
|
assert_equal "ASCII-8BIT", txt_1.encoding.to_s
|
||
|
assert_equal "ASCII-8BIT", txt_2.encoding.to_s
|
||
|
assert_equal "ASCII-8BIT", txt_3.encoding.to_s
|
||
| ... | ... | |
|
end
|
||
|
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_en
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str1 = "Texte encod\xE9 en ISO-8859-1"
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, 'UTF-8')
|
||
|
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, 'UTF-8')
|
||
|
assert_equal "ASCII-8BIT", txt_1.encoding.to_s
|
||
| ... | ... | |
|
end
|
||
|
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str1 = "Texte encod\xE9 en ISO-8859-1"
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
encoding = ( RUBY_PLATFORM == 'java' ? "SJIS" : "CP932" )
|
||
|
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, encoding)
|
||
|
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, encoding)
|
||
| ... | ... | |
|
["CP932", "SJIS"].each do |encoding|
|
||
|
set_fixtures_attachments_directory
|
||
|
str2 = "\x83e\x83X\x83g".force_encoding("ASCII-8BIT")
|
||
|
str2 = (+"\x83e\x83X\x83g").force_encoding("ASCII-8BIT")
|
||
|
a1 = Attachment.find(17)
|
||
|
a2 = Attachment.find(19)
|
||
| test/unit/lib/redmine/i18n_test.rb | ||
|---|---|---|
|
end
|
||
|
assert l('date.day_names').is_a?(Array)
|
||
|
assert_equal 7, l('date.day_names').size
|
||
|
|
||
|
assert l('date.month_names').is_a?(Array)
|
||
|
assert_equal 13, l('date.month_names').size
|
||
|
end
|
||
| ... | ... | |
|
set_language_if_valid 'bs'
|
||
|
assert_equal "KM -1000,20", number_to_currency(-1000.2)
|
||
|
set_language_if_valid 'de'
|
||
|
euro_sign = "\xe2\x82\xac".force_encoding('UTF-8')
|
||
|
assert_equal "-1000,20 #{euro_sign}", number_to_currency(-1000.2)
|
||
|
assert_equal '-1000,20 €', number_to_currency(-1000.2)
|
||
|
end
|
||
|
def test_lu_should_not_error_when_user_language_is_an_empty_string
|
||
| ... | ... | |
|
assert_nil options.detect {|option| option.size != 2}
|
||
|
assert_nil options.detect {|option| !option.first.is_a?(String) || !option.last.is_a?(String)}
|
||
|
assert_include ["English", "en"], options
|
||
|
ja = "Japanese (\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e)".force_encoding('UTF-8')
|
||
|
assert_include [ja, "ja"], options
|
||
|
assert_include ['Japanese (日本語)', "ja"], options
|
||
|
end
|
||
|
def test_languages_options_should_return_strings_with_utf8_encoding
|
||
| ... | ... | |
|
def test_utf8
|
||
|
set_language_if_valid 'ja'
|
||
|
str_ja_yes = "\xe3\x81\xaf\xe3\x81\x84".force_encoding('UTF-8')
|
||
|
i18n_ja_yes = l(:general_text_Yes)
|
||
|
assert_equal str_ja_yes, i18n_ja_yes
|
||
|
assert_equal 'はい', i18n_ja_yes
|
||
|
assert_equal "UTF-8", i18n_ja_yes.encoding.to_s
|
||
|
end
|
||
|
def test_traditional_chinese_locale
|
||
|
set_language_if_valid 'zh-TW'
|
||
|
str_tw = "Chinese/Traditional (\xE7\xB9\x81\xE9\xAB\x94\xE4\xB8\xAD\xE6\x96\x87)".force_encoding('UTF-8')
|
||
|
assert_equal str_tw, l(:general_lang_name)
|
||
|
assert_equal 'Chinese/Traditional (繁體中文)', l(:general_lang_name)
|
||
|
end
|
||
|
def test_french_locale
|
||
|
set_language_if_valid 'fr'
|
||
|
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8')
|
||
|
assert_equal str_fr, l(:general_lang_name)
|
||
|
assert_equal 'French (Français)', l(:general_lang_name)
|
||
|
end
|
||
|
end
|
||
| test/unit/lib/redmine/scm/adapters/git_adapter_test.rb | ||
|---|---|---|
|
class GitAdapterTest < ActiveSupport::TestCase
|
||
|
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||
|
FELIX_HEX = "Felix Sch\xC3\xA4fer"
|
||
|
CHAR_1_HEX = "\xc3\x9c"
|
||
|
## Git, Mercurial and CVS path encodings are binary.
|
||
|
## Subversion supports URL encoding for path.
|
||
|
## Redmine Mercurial adapter and extension use URL encoding.
|
||
| ... | ... | |
|
'ISO-8859-1'
|
||
|
)
|
||
|
assert @adapter
|
||
|
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8')
|
||
|
@str_felix_hex = FELIX_HEX.dup.force_encoding('ASCII-8BIT')
|
||
|
@char_1 = 'Ü'
|
||
|
@str_felix_hex = (+"Felix Sch\xC3\xA4fer").force_encoding('ASCII-8BIT')
|
||
|
end
|
||
|
def test_scm_version
|
||
| ... | ... | |
|
end
|
||
|
assert_equal 6, brs.length
|
||
|
br_issue_8857 = brs[0]
|
||
|
assert_equal 'issue-8857', br_issue_8857.to_s
|
||
|
assert_equal 'issue-8857', br_issue_8857.to_s
|
||
|
assert_equal '2a682156a3b6e77a8bf9cd4590e8db757f3c6c78', br_issue_8857.revision
|
||
|
assert_equal br_issue_8857.scmid, br_issue_8857.revision
|
||
|
assert_equal false, br_issue_8857.is_default
|
||
|
br_latin_1_path = brs[1]
|
||
|
assert_equal 'latin-1-path-encoding', br_latin_1_path.to_s
|
||
|
assert_equal 'latin-1-path-encoding', br_latin_1_path.to_s
|
||
|
assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', br_latin_1_path.revision
|
||
|
assert_equal br_latin_1_path.scmid, br_latin_1_path.revision
|
||
|
assert_equal false, br_latin_1_path.is_default
|
||
| test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb | ||
|---|---|---|
|
HgCommandArgumentError = Redmine::Scm::Adapters::MercurialAdapter::HgCommandArgumentError
|
||
|
REPOSITORY_PATH = repository_path('mercurial')
|
||
|
CHAR_1_HEX = "\xc3\x9c"
|
||
|
if File.directory?(REPOSITORY_PATH)
|
||
|
def setup
|
||
| ... | ... | |
|
nil,
|
||
|
'ISO-8859-1')
|
||
|
@diff_c_support = true
|
||
|
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8')
|
||
|
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||
|
@char_1 = 'Ü'
|
||
|
@tag_char_1 = 'tag-Ü-00'
|
||
|
@branch_char_0 = 'branch-Ü-00'
|
||
|
@branch_char_1 = 'branch-Ü-01'
|
||
|
end
|
||
|
def test_hgversion
|
||
| test/unit/lib/redmine/unified_diff_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_utf8_ja
|
||
|
ja = " text_tip_issue_end_day: "
|
||
|
ja += "\xe3\x81\x93\xe3\x81\xae\xe6\x97\xa5\xe3\x81\xab\xe7\xb5\x82\xe4\xba\x86\xe3\x81\x99\xe3\x82\x8b<span>\xe3\x82\xbf\xe3\x82\xb9\xe3\x82\xaf</span>".force_encoding('UTF-8')
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ja.diff'), :type => 'inline')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 12, diff.first.size
|
||
|
assert_equal ja, diff.first[4].html_line_left
|
||
|
assert_equal ' text_tip_issue_end_day: この日に終了する<span>タスク</span>', diff.first[4].html_line_left
|
||
|
end
|
||
|
end
|
||
|
def test_utf8_ru
|
||
|
ru = " other: "\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe %{count} \xd1\x87\xd0\xb0\xd1\x81<span>\xd0\xb0</span>"".force_encoding('UTF-8')
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ru.diff'), :type => 'inline')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 8, diff.first.size
|
||
|
assert_equal ru, diff.first[3].html_line_left
|
||
|
assert_equal ' other: "около %{count} час<span>а</span>"', diff.first[3].html_line_left
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
def test_offset_range_japanese_1
|
||
|
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span></span>".force_encoding('UTF-8')
|
||
|
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x9e</span>".force_encoding('UTF-8')
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(
|
||
|
read_diff_fixture('issue-13644-1.diff'), :type => 'sbs')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 3, diff.first.size
|
||
|
assert_equal ja1, diff.first[1].html_line_left
|
||
|
assert_equal ja2, diff.first[1].html_line_right
|
||
|
assert_equal '日本<span></span>', diff.first[1].html_line_left
|
||
|
assert_equal '日本<span>語</span>', diff.first[1].html_line_right
|
||
|
end
|
||
|
end
|
||
|
def test_offset_range_japanese_2
|
||
|
ja1 = "<span></span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8')
|
||
|
ja2 = "<span>\xe3\x81\xab\xe3\x81\xa3\xe3\x81\xbd\xe3\x82\x93</span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8')
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(
|
||
|
read_diff_fixture('issue-13644-2.diff'), :type => 'sbs')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 3, diff.first.size
|
||
|
assert_equal ja1, diff.first[1].html_line_left
|
||
|
assert_equal ja2, diff.first[1].html_line_right
|
||
|
assert_equal '<span></span>日本', diff.first[1].html_line_left
|
||
|
assert_equal '<span>にっぽん</span>日本', diff.first[1].html_line_right
|
||
|
end
|
||
|
end
|
||
|
def test_offset_range_japanese_3
|
||
|
# UTF-8 The 1st byte differs.
|
||
|
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8')
|
||
|
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>".force_encoding('UTF-8')
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(
|
||
|
read_diff_fixture('issue-13644-3.diff'), :type => 'sbs')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 3, diff.first.size
|
||
|
assert_equal ja1, diff.first[1].html_line_left
|
||
|
assert_equal ja2, diff.first[1].html_line_right
|
||
|
assert_equal '日本<span>記</span>', diff.first[1].html_line_left
|
||
|
assert_equal '日本<span>娘</span>', diff.first[1].html_line_right
|
||
|
end
|
||
|
end
|
||
|
def test_offset_range_japanese_4
|
||
|
# UTF-8 The 2nd byte differs.
|
||
|
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8')
|
||
|
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>".force_encoding('UTF-8')
|
||
|
# UTF-8 The 2nd byte differs.
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(
|
||
|
read_diff_fixture('issue-13644-4.diff'), :type => 'sbs')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 3, diff.first.size
|
||
|
assert_equal ja1, diff.first[1].html_line_left
|
||
|
assert_equal ja2, diff.first[1].html_line_right
|
||
|
assert_equal '日本<span>記</span>', diff.first[1].html_line_left
|
||
|
assert_equal '日本<span>誘</span>', diff.first[1].html_line_right
|
||
|
end
|
||
|
end
|
||
|
def test_offset_range_japanese_5
|
||
|
# UTF-8 The 2nd byte differs.
|
||
|
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>ok".force_encoding('UTF-8')
|
||
|
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok".force_encoding('UTF-8')
|
||
|
# UTF-8 The 2nd byte differs.
|
||
|
with_settings :repositories_encodings => '' do
|
||
|
diff = Redmine::UnifiedDiff.new(
|
||
|
read_diff_fixture('issue-13644-5.diff'), :type => 'sbs')
|
||
|
assert_equal 1, diff.size
|
||
|
assert_equal 3, diff.first.size
|
||
|
assert_equal ja1, diff.first[1].html_line_left
|
||
|
assert_equal ja2, diff.first[1].html_line_right
|
||
|
assert_equal '日本<span>記</span>ok', diff.first[1].html_line_left
|
||
|
assert_equal '日本<span>誘</span>ok', diff.first[1].html_line_right
|
||
|
end
|
||
|
end
|
||
| test/unit/mail_handler_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_add_issue_with_japanese_keywords
|
||
|
ja_dev = "\xe9\x96\x8b\xe7\x99\xba".force_encoding('UTF-8')
|
||
|
tracker = Tracker.generate!(:name => ja_dev)
|
||
|
tracker = Tracker.generate!(:name => '開発')
|
||
|
Project.find(1).trackers << tracker
|
||
|
issue = submit_email(
|
||
|
'japanese_keywords_iso_2022_jp.eml',
|
||
| ... | ... | |
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal 1, issue.attachments.size
|
||
|
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8')
|
||
|
attachment = issue.attachments.first
|
||
|
assert_equal ja, attachment.filename
|
||
|
assert_equal 'テスト.txt', attachment.filename
|
||
|
assert_equal 5, attachment.filesize
|
||
|
assert File.exist?(attachment.diskfile)
|
||
|
assert_equal 5, File.size(attachment.diskfile)
|
||
| ... | ... | |
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
description = "\xD0\x97\xD0\xB4\xD1\x80\xD0\xB0\xD0\xB2\xD1\x81\xD1\x82\xD0\xB2\xD1\x83\xD0\xB9\xD1\x82\xD0\xB5?".force_encoding('UTF-8')
|
||
|
assert_equal description, issue.description
|
||
|
assert_equal 'Здравствуйте?', issue.description
|
||
|
end
|
||
|
def test_gmail_with_attachment_ja
|
||
| ... | ... | |
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal 1, issue.attachments.size
|
||
|
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8')
|
||
|
attachment = issue.attachments.first
|
||
|
assert_equal ja, attachment.filename
|
||
|
assert_equal 'テスト.txt', attachment.filename
|
||
|
assert_equal 5, attachment.filesize
|
||
|
assert File.exist?(attachment.diskfile)
|
||
|
assert_equal 5, File.size(attachment.diskfile)
|
||
| ... | ... | |
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal 1, issue.attachments.size
|
||
|
u = "".force_encoding('UTF-8')
|
||
|
u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8')
|
||
|
u = +''
|
||
|
u1 = 'ÄäÖöÜü'
|
||
|
11.times { u << u1 }
|
||
|
attachment = issue.attachments.first
|
||
|
assert_equal "#{u}.png", attachment.filename
|
||
| ... | ... | |
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal 1, issue.attachments.size
|
||
|
u = "".force_encoding('UTF-8')
|
||
|
u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8')
|
||
|
u = +''
|
||
|
u1 = 'ÄäÖöÜü'
|
||
|
11.times { u << u1 }
|
||
|
attachment = issue.attachments.first
|
||
|
assert_equal "#{u}.txt", attachment.filename
|
||
| ... | ... | |
|
assert_equal 19, attachment.filesize
|
||
|
assert File.exist?(attachment.diskfile)
|
||
|
assert_equal 19, File.size(attachment.diskfile)
|
||
|
content = "p\xF8\xEDli\xB9 \xBEluou\xE8k\xFD k\xF9n".force_encoding('CP852')
|
||
|
content = (+"p\xF8\xEDli\xB9 \xBEluou\xE8k\xFD k\xF9n").force_encoding('CP852')
|
||
|
assert_equal content, File.read(attachment.diskfile).force_encoding('CP852')
|
||
|
end
|
||
| ... | ... | |
|
'subject_as_iso-8859-1.eml',
|
||
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc...".force_encoding('UTF-8')
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal str, issue.subject
|
||
|
assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject
|
||
|
end
|
||
|
def test_quoted_printable_utf8
|
||
| ... | ... | |
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
str = "Freundliche Gr\xc3\xbcsse".force_encoding('UTF-8')
|
||
|
assert_equal str, issue.description
|
||
|
assert_equal 'Freundliche Grüsse', issue.description
|
||
|
end
|
||
|
def test_gmail_iso8859_2
|
||
| ... | ... | |
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
str = "Na \xc5\xa1triku se su\xc5\xa1i \xc5\xa1osi\xc4\x87.".force_encoding('UTF-8')
|
||
|
assert issue.description.include?(str)
|
||
|
assert issue.description.include?('Na štriku se suši šosić.')
|
||
|
end
|
||
|
def test_add_issue_with_japanese_subject
|
||
| ... | ... | |
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8')
|
||
|
assert_equal ja, issue.subject
|
||
|
assert_equal 'テスト', issue.subject
|
||
|
end
|
||
|
def test_add_issue_with_korean_body
|
||
|
# Make sure mail bodies with a charset unknown to Ruby
|
||
|
# but known to the Mail gem 2.5.4 are handled correctly
|
||
|
kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4.".force_encoding('UTF-8')
|
||
|
issue = submit_email(
|
||
|
'body_ks_c_5601-1987.eml',
|
||
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
assert_equal kr, issue.description
|
||
|
assert_equal '고맙습니다.', issue.description
|
||
|
end
|
||
|
def test_add_issue_with_no_subject_header
|
||
| ... | ... | |
|
:issue => {:project => 'ecookbook'}
|
||
|
)
|
||
|
assert_kind_of Issue, issue
|
||
|
ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8')
|
||
|
assert_equal ja, issue.subject
|
||
|
assert_equal 'Re: テスト', issue.subject
|
||
|
end
|
||
|
def test_add_issue_with_iso_2022_jp_ms_subject
|
||
| ... | ... | |
|
end
|
||
|
user = User.order('id DESC').first
|
||
|
assert_equal "foo@example.org", user.mail
|
||
|
str1 = "\xc3\x84\xc3\xa4".force_encoding('UTF-8')
|
||
|
str2 = "\xc3\x96\xc3\xb6".force_encoding('UTF-8')
|
||
|
assert_equal str1, user.firstname
|
||
|
assert_equal str2, user.lastname
|
||
|
assert_equal 'Ää', user.firstname
|
||
|
assert_equal 'Öö', user.lastname
|
||
|
end
|
||
|
def test_new_user_with_fullname_in_parentheses
|
||
| test/unit/member_test.rb | ||
|---|---|---|
|
member = Member.new(:project_id => 1, :user_id => user.id, :role_ids => [])
|
||
|
assert !member.save
|
||
|
assert_include I18n.translate('activerecord.errors.messages.empty'), member.errors[:role]
|
||
|
assert_equal "R\xc3\xb4le doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8'),
|
||
|
assert_equal 'Rôle doit être renseigné(e)',
|
||
|
[member.errors.full_messages].flatten.join
|
||
|
end
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
def test_label_for_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
q = IssueQuery.new
|
||
|
assert_equal "Assign\xc3\xa9 \xc3\xa0".force_encoding('UTF-8'), q.label_for('assigned_to_id')
|
||
|
assert_equal 'Assigné à', q.label_for('assigned_to_id')
|
||
|
end
|
||
|
def test_editable_by
|
||
| test/unit/repository_bazaar_test.rb | ||
|---|---|---|
|
RUN_LATIN1_OUTPUT_TEST = (RUBY_PLATFORM != 'java' &&
|
||
|
Encoding.locale_charmap == "ISO-8859-1")
|
||
|
CHAR_1_UTF8_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||
|
CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT')
|
||
|
CHAR_1_UTF8_HEX = 'Ü'
|
||
|
CHAR_1_LATIN1_HEX = (+"\xdc").force_encoding('ASCII-8BIT')
|
||
|
def setup
|
||
|
User.current = nil
|
||
| ... | ... | |
|
def test_blank_path_to_repository_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Bazaar.new(
|
||
|
:project => @project,
|
||
|
:url => "",
|
||
| ... | ... | |
|
:log_encoding => 'UTF-8'
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
if File.directory?(REPOSITORY_PATH_TRUNK)
|
||
| test/unit/repository_cvs_test.rb | ||
|---|---|---|
|
def test_blank_module_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Cvs.new(
|
||
|
:project => @project,
|
||
|
:identifier => 'test',
|
||
| ... | ... | |
|
:root_url => REPOSITORY_PATH
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Module doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
def test_blank_cvsroot_error_message
|
||
| ... | ... | |
|
def test_blank_cvsroot_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Cvs.new(
|
||
|
:project => @project,
|
||
|
:identifier => 'test',
|
||
| ... | ... | |
|
:root_url => ''
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'CVSROOT doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
def test_root_url_should_be_validated_against_regexp_set_in_configuration
|
||
| test/unit/repository_filesystem_test.rb | ||
|---|---|---|
|
def test_blank_root_directory_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Filesystem.new(
|
||
|
:project => @project,
|
||
|
:url => "",
|
||
| ... | ... | |
|
:path_encoding => ''
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Répertoire racine doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
if File.directory?(REPOSITORY_PATH)
|
||
| test/unit/repository_git_test.rb | ||
|---|---|---|
|
NUM_REV = 28
|
||
|
NUM_HEAD = 6
|
||
|
FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8')
|
||
|
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||
|
## Git, Mercurial and CVS path encodings are binary.
|
||
|
## Subversion supports URL encoding for path.
|
||
|
## Redmine Mercurial adapter and extension use URL encoding.
|
||
| ... | ... | |
|
def test_blank_path_to_repository_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Git.new(
|
||
|
:project => @project,
|
||
|
:url => "",
|
||
| ... | ... | |
|
:path_encoding => ''
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
if File.directory?(REPOSITORY_PATH)
|
||
| ... | ... | |
|
else
|
||
|
# latin-1 encoding path
|
||
|
changesets = @repository.latest_changesets(
|
||
|
"latin-1-dir/test-#{CHAR_1_HEX}-2.txt", '64f1f3e89')
|
||
|
'latin-1-dir/test-Ü-2.txt', '64f1f3e89')
|
||
|
assert_equal [
|
||
|
'64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
|
||
|
'4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
|
||
|
], changesets.collect(&:revision)
|
||
|
changesets = @repository.latest_changesets(
|
||
|
"latin-1-dir/test-#{CHAR_1_HEX}-2.txt", '64f1f3e89', 1)
|
||
|
'latin-1-dir/test-Ü-2.txt', '64f1f3e89', 1)
|
||
|
assert_equal [
|
||
|
'64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
|
||
|
], changesets.collect(&:revision)
|
||
| ... | ... | |
|
@project.reload
|
||
|
assert_equal NUM_REV, @repository.changesets.count
|
||
|
changesets = @repository.latest_changesets(
|
||
|
"latin-1-dir/test-#{CHAR_1_HEX}-subdir", '1ca7f5ed')
|
||
|
'latin-1-dir/test-Ü-subdir', '1ca7f5ed')
|
||
|
assert_equal [
|
||
|
'1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
|
||
|
], changesets.collect(&:revision)
|
||
| ... | ... | |
|
assert_equal NUM_REV, @repository.changesets.count
|
||
|
c = @repository.changesets.find_by_revision(
|
||
|
'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
|
||
|
assert_equal "#{FELIX_HEX} <felix@fachschaften.org>", c.committer
|
||
|
assert_equal 'Felix Schäfer <felix@fachschaften.org>', c.committer
|
||
|
end
|
||
|
def test_previous
|
||
| test/unit/repository_mercurial_test.rb | ||
|---|---|---|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
|
||
|
NUM_REV = 34
|
||
|
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||
|
BRANCH_CHAR_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||
|
def setup
|
||
|
User.current = nil
|
||
|
@project = Project.find(3)
|
||
| ... | ... | |
|
def test_blank_path_to_repository_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Mercurial.new(
|
||
|
:project => @project,
|
||
|
:url => "",
|
||
| ... | ... | |
|
:path_encoding => ''
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
if File.directory?(REPOSITORY_PATH)
|
||
| ... | ... | |
|
assert_equal NUM_REV, @repository.changesets.count
|
||
|
if @repository.scm.class.client_version_above?([1, 6])
|
||
|
changesets = @repository.latest_changesets('', BRANCH_CHAR_1)
|
||
|
changesets = @repository.latest_changesets('', 'branch-Ü-01')
|
||
|
assert_equal %w|27 26|, changesets.collect(&:revision)
|
||
|
end
|
||
|
changesets = @repository.latest_changesets("latin-1-dir/test-#{CHAR_1_HEX}-subdir", BRANCH_CHAR_1)
|
||
|
changesets = @repository.latest_changesets('latin-1-dir/test-Ü-subdir', 'branch-Ü-01')
|
||
|
assert_equal %w|27|, changesets.collect(&:revision)
|
||
|
end
|
||
| ... | ... | |
|
scmid3 = scmid_for_assert(hex3, is_short_scmid)
|
||
|
assert_equal 1, c3.size
|
||
|
assert_equal 'A', c3[0].action
|
||
|
assert_equal "/latin-1-dir/test-#{CHAR_1_HEX}-1.txt", c3[0].path
|
||
|
assert_equal "/latin-1-dir/test-#{CHAR_1_HEX}.txt", c3[0].from_path
|
||
|
assert_equal '/latin-1-dir/test-Ü-1.txt', c3[0].path
|
||
|
assert_equal '/latin-1-dir/test-Ü.txt', c3[0].from_path
|
||
|
assert_equal scmid3, c3[0].from_revision
|
||
|
end
|
||
|
private :assert_copied_files
|
||
| test/unit/repository_subversion_test.rb | ||
|---|---|---|
|
def test_log_encoding_ignore_setting
|
||
|
with_settings :commit_logs_encoding => 'windows-1252' do
|
||
|
s2 = "\xc3\x82\xc2\x80".force_encoding('UTF-8')
|
||
|
s2 = "Â\u0080"
|
||
|
c = Changeset.new(:repository => @repository,
|
||
|
:comments => s2,
|
||
|
:revision => '123',
|
||
| test/unit/repository_test.rb | ||
|---|---|---|
|
def test_blank_log_encoding_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Encodage des messages de commit doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
repo = Repository::Bazaar.new(
|
||
|
:project => Project.find(3),
|
||
|
:url => "/test"
|
||
|
)
|
||
|
assert !repo.save
|
||
|
assert_include str, repo.errors.full_messages
|
||
|
assert_include 'Encodage des messages de commit doit être renseigné(e)', repo.errors.full_messages
|
||
|
end
|
||
|
def test_create
|
||
| ... | ... | |
|
:url => '/foo/bar/baz' )
|
||
|
long_whitespace = " "
|
||
|
expected_comment = "This is a loooooooooooooooooooooooooooong comment"
|
||
|
comment = "#{expected_comment}#{long_whitespace}\n"
|
||
|
comment = +"#{expected_comment}#{long_whitespace}\n"
|
||
|
3.times {comment << "#{long_whitespace}\n"}
|
||
|
changeset = Changeset.new(
|
||
|
:comments => comment, :commit_date => Time.now,
|
||
| test/unit/wiki_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_titleize
|
||
|
ja_test = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8')
|
||
|
ja_test = 'テスト'
|
||
|
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
|
||
|
assert_equal ja_test, Wiki.titleize(ja_test)
|
||
|
end
|
||