Attachment sort doesn't work with Unicode
|Target version:||Candidate for next major release|
#2 Updated by Toshi MARUYAMA over 2 years ago
Could you add test?
#3 Updated by Go MAEDA over 2 years ago
#5 Updated by Go MAEDA over 1 year ago
- Target version set to Candidate for next major release
We can merge this patch if Redmine migrates to Rails 6 (maybe in Redmine 5?).
#8 Updated by Go MAEDA about 1 year ago
Go MAEDA wrote:
But the patch needs some improvements because Ruby older than 2.4 don't have
casecmp?(https://github.com/ruby/ruby/blob/v2_4_0/NEWS). The upcoming Redmine 4.0.0 supports Ruby 2.2.2 and later (#25538).
We can apply the patch provided by Амир Мусин and fix the issue for Ruby >=2.4 right now if we define
String#casecmp? method like the following.
Even if we define the method, the problem will not fe fixed under Ruby 2.3 because the fake
String#casecmp? is not Unicode-aware unlike the genuine
String#casecmp?. But I think it is OK because the Ruby team has ended support for 2.3 last month and probably many people who use the latest version of Redmine don't use such old Ruby.
We can delete the definition when Redmine has dropped the support for Ruby 2.3.
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index e0559903b..0154de257 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -213,3 +213,12 @@ module ActionView end end end + +if RUBY_VERSION < '2.4' + class String + # bahaves like String#casecmp? but does not support Unicode + def casecmp?(other) + self.casecmp(other).zero? + end + end +end