Project

General

Profile

Actions

Backport #7911

closed

特定の条件の時に、File.fnmatchに渡すpatternがUS-ASCII、pathがUTF-8だとInvalid sequenceでエラーが出る

Added by grafi (Shunsuke Shimizu) about 11 years ago. Updated about 11 years ago.


Description

=begin

coding: utf-8

File.fnmatch('a'.encode('US-ASCII'), 'あ', File::FNM_CASEFOLD)

というコードを実行した際に、

test-fnmatch.rb:2:in fnmatch': invalid byte sequence in US-ASCII (ArgumentError) from test-fnmatch.rb:2:in '

というエラーが発生します。UTF-8文字列である'あ'を、'a'と同じUS-ASCIIだとしてcase insenstiveなマッチのためにupcaseを試みているのがエラー原因と思われます。

添付のパッチで動作するようになることを確認しました。
=end


Files

fix-fnmatch.patch (967 Bytes) fix-fnmatch.patch grafi (Shunsuke Shimizu), 02/22/2013 07:00 PM
Actions #1

Updated by ko1 (Koichi Sasada) about 11 years ago

  • Category set to M17N
  • Assignee set to naruse (Yui NARUSE)
  • Target version set to 2.1.0

naruse さんに 2.1.0 として振りますが、2.0.0 に必要かどうかはご判断下さい。

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39413.
Shunsuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


dir.c: encoding check

  • dir.c (file_s_fnmatch, fnmatch_brace): encoding-incompatible pattern
    and string do not match, instead of exception. [ruby-dev:47069]
    [Bug #7911]
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Category deleted (M17N)
  • Status changed from Closed to Assigned
  • Assignee changed from naruse (Yui NARUSE) to mame (Yusuke Endoh)
  • Target version deleted (2.1.0)

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Assignee changed from mame (Yusuke Endoh) to nagachika (Tomoyuki Chikanaga)
Actions #5

Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r39662.
Shunsuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 39413: [Backport #7911]

* dir.c (file_s_fnmatch, fnmatch_brace): encoding-incompatible pattern
  and string do not match, instead of exception.  [ruby-dev:47069]
  [Bug #7911]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0