Defect #13644 » unified_diff.rb_r12041.diff
| test/unit/lib/redmine/unified_diff_test.rb (working copy) | ||
|---|---|---|
| 308 | 308 |
end |
| 309 | 309 |
end |
| 310 | 310 | |
| 311 |
def test_offset_range_japanese_3 |
|
| 312 |
# UTF-8 The 1st byte differs. |
|
| 313 |
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>" |
|
| 314 |
ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
|
|
| 315 |
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>" |
|
| 316 |
ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
|
|
| 317 |
with_settings :repositories_encodings => '' do |
|
| 318 |
diff = Redmine::UnifiedDiff.new( |
|
| 319 |
read_diff_fixture('issue-13644-3.diff'), :type => 'sbs')
|
|
| 320 |
assert_equal 1, diff.size |
|
| 321 |
assert_equal 3, diff.first.size |
|
| 322 |
assert_equal ja1, diff.first[1].html_line_left |
|
| 323 |
assert_equal ja2, diff.first[1].html_line_right |
|
| 324 |
end |
|
| 325 |
end |
|
| 326 | ||
| 327 |
def test_offset_range_japanese_4 |
|
| 328 |
# UTF-8 The 2nd byte differs. |
|
| 329 |
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>" |
|
| 330 |
ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
|
|
| 331 |
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>" |
|
| 332 |
ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
|
|
| 333 |
with_settings :repositories_encodings => '' do |
|
| 334 |
diff = Redmine::UnifiedDiff.new( |
|
| 335 |
read_diff_fixture('issue-13644-4.diff'), :type => 'sbs')
|
|
| 336 |
assert_equal 1, diff.size |
|
| 337 |
assert_equal 3, diff.first.size |
|
| 338 |
assert_equal ja1, diff.first[1].html_line_left |
|
| 339 |
assert_equal ja2, diff.first[1].html_line_right |
|
| 340 |
end |
|
| 341 |
end |
|
| 342 | ||
| 343 |
def test_offset_range_japanese_5 |
|
| 344 |
# UTF-8 The 2nd byte differs. |
|
| 345 |
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>ok" |
|
| 346 |
ja1.force_encoding('UTF-8') if ja1.respond_to?(:force_encoding)
|
|
| 347 |
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok" |
|
| 348 |
ja2.force_encoding('UTF-8') if ja2.respond_to?(:force_encoding)
|
|
| 349 |
with_settings :repositories_encodings => '' do |
|
| 350 |
diff = Redmine::UnifiedDiff.new( |
|
| 351 |
read_diff_fixture('issue-13644-5.diff'), :type => 'sbs')
|
|
| 352 |
assert_equal 1, diff.size |
|
| 353 |
assert_equal 3, diff.first.size |
|
| 354 |
assert_equal ja1, diff.first[1].html_line_left |
|
| 355 |
assert_equal ja2, diff.first[1].html_line_right |
|
| 356 |
end |
|
| 357 |
end |
|
| 358 | ||
| 311 | 359 |
private |
| 312 | 360 | |
| 313 | 361 |
def read_diff_fixture(filename) |
| test/fixtures/diffs/issue-13644-4.diff (revision 0) | ||
|---|---|---|
| 1 |
--- a.txt 2013-07-27 04:20:45.973229414 +0900 |
|
| 2 |
+++ b.txt 2013-07-27 04:20:52.366228105 +0900 |
|
| 3 |
@@ -1,3 +1,3 @@ |
|
| 4 |
aaaa |
|
| 5 |
-日本記 |
|
| 6 |
+日本誘 |
|
| 7 |
bbbb |
|
| test/fixtures/diffs/issue-13644-5.diff (revision 0) | ||
|---|---|---|
| 1 |
--- a.txt 2013-07-27 05:52:11.415223830 +0900 |
|
| 2 |
+++ b.txt 2013-07-27 05:52:18.249190358 +0900 |
|
| 3 |
@@ -1,3 +1,3 @@ |
|
| 4 |
aaaa |
|
| 5 |
-日本記ok |
|
| 6 |
+日本誘ok |
|
| 7 |
bbbb |
|
| test/fixtures/diffs/issue-13644-3.diff (revision 0) | ||
|---|---|---|
| 1 |
--- a.txt 2013-07-27 06:03:49.133257759 +0900 |
|
| 2 |
+++ b.txt 2013-07-27 06:03:58.791221118 +0900 |
|
| 3 |
@@ -1,3 +1,3 @@ |
|
| 4 |
aaaa |
|
| 5 |
-日本記 |
|
| 6 |
+日本娘 |
|
| 7 |
bbbb |
|
| lib/redmine/unified_diff.rb (working copy) | ||
|---|---|---|
| 205 | 205 |
end |
| 206 | 206 |
end |
| 207 | 207 |
ending = -1 |
| 208 |
while ending >= -(max - starting) && line_left[ending] == line_right[ending]
|
|
| 208 |
while ending >= -(max - starting) && (line_left[ending] == line_right[ending])
|
|
| 209 | 209 |
ending -= 1 |
| 210 | 210 |
end |
| 211 | 211 |
if (! "".respond_to?(:force_encoding)) && ending > (-1 * line_left.size) |
| 212 |
while line_left[ending].ord.between?(128, 191) && ending > -1 |
|
| 213 |
ending -= 1 |
|
| 212 |
while line_left[ending].ord.between?(128, 255) && ending < -1 |
|
| 213 |
if line_left[ending].ord.between?(128, 191) |
|
| 214 |
if line_left[ending + 1].ord.between?(128, 191) |
|
| 215 |
ending += 1 |
|
| 216 |
else |
|
| 217 |
break |
|
| 218 |
end |
|
| 219 |
else |
|
| 220 |
ending += 1 |
|
| 221 |
end |
|
| 214 | 222 |
end |
| 215 | 223 |
end |
| 216 | 224 |
unless starting == 0 && ending == -1 |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »