プロジェクト

全般

プロフィール

Vote #79007

完了

Case-insensitive matching fails for Unicode filenames when referring to attachments in text formatting

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
152
issue_org_id:
27780
author_id:
333606
assigned_to_id:
332
comments:
15
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

casecmp method doesn't work with Unicode symbol - https://bugs.ruby-lang.org/issues/14055
decision is to use casecmp? instead of casecmp - https://bugs.ruby-lang.org/issues/12786


journals

--------------------------------------------------------------------------------
Could you add test?
source:trunk/test/unit/attachment_test.rb@17111#L386
--------------------------------------------------------------------------------
Амир Мусин, thank you for reporting the problem and providing the patch.

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 merge this patch if Redmine migrates to Rails 6 (maybe in Redmine 5?).

"Rails 6 requires Ruby 2.4.1+ by jeremy · Pull Request #32034 · rails/rails":https://github.com/rails/rails/pull/32034

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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.

<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Go MAEDA wrote:
> 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.

It is not necessary now because the trunk dropped support for Ruby 2.3 (#34142).
--------------------------------------------------------------------------------
Added test code to Амир Мусин's patch.
--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
Looks good to me.
--------------------------------------------------------------------------------
Committed the fix.
--------------------------------------------------------------------------------


related_issues

relates,Closed,20369,Use String#casecmp for case insensitive comparison
relates,Closed,30441,Attachments with Unicode uppercase names are not shown in wiki pages
relates,Closed,34142,Drop Ruby 2.3 support

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0