Project

General

Profile

Actions

Bug #5913

closed

CGI.escape cannot escape a string with invalid byte sequence.

Added by mrkn (Kenta Murata) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.0.0dev (2012-01-20 trunk 34342) [x86_64-darwin11.2.0]
Backport:
[ruby-dev:45139]

Description

不正なバイト列を持つ文字列を CGI.escape に渡すと ArgumentError が起きます。

$ .prefix/bin/ruby -rcgi -ve 'p CGI.escape("\xC0<<".force_encoding("UTF-8"))'
ruby 2.0.0dev (2012-01-20 trunk 34342) [x86_64-darwin11.2.0]
/Users/kenta-murata/work/ruby.git/.prefix/lib/ruby/2.0.0/cgi/util.rb:7:in gsub': invalid byte sequence in UTF-8 (ArgumentError) from /Users/kenta-murata/work/ruby.git/.prefix/lib/ruby/2.0.0/cgi/util.rb:7:in escape'
from -e:1:in `'

この振舞いがバグなら、このパッチで修正可能です https://gist.github.com/1646048

Actions

Also available in: Atom PDF