Project

General

Profile

This project is closed and read-only.

Actions

Backport #7911

closed

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

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

Added by grafi (Shunsuke Shimizu) over 13 years ago. Updated over 13 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

Updated by ko1 (Koichi Sasada) over 13 years ago Actions #1

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

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

Updated by nobu (Nobuyoshi Nakada) over 13 years ago Actions #2

  • 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]

Updated by nobu (Nobuyoshi Nakada) over 13 years ago Actions #3

  • Tracker changed from Bug to Backport
  • Project changed from Ruby to 15
  • 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) over 13 years ago Actions #4 [ruby-dev:47151]

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

Updated by nagachika (Tomoyuki Chikanaga) over 13 years ago Actions #5

  • 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: PDF Atom