Project

General

Profile

Actions

Feature #542

closed

cgi.rb : CGI::unescape return encoding

Added by xibbar (Takeyuki FUJIOKA) about 16 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
-
[ruby-dev:36132]

Description

=begin
CGI::unescapeは現在は引数のencodingでforce_encodingするように
なっていますが、ascii_only?がtrueの場合はUS-ASCII、
falseの場合はASCII-8BITを返すのがいいと思います。

Index: lib/cgi.rb

--- lib/cgi.rb (リビジョン 19071)
+++ lib/cgi.rb (作業コピー)
@@ -349,10 +349,10 @@
# string = CGI::unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def CGI::unescape(string)

  • enc = string.encoding
  • string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
  •  [$1.delete('%')].pack('H*').force_encoding(enc)
    
  • str=string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
  •  [$1.delete('%')].pack('H*')
    
    end
  • str.ascii_only? ? str.force_encoding("US-ASCII") : str.force_encoding("ASCII-8BIT")
    end
TABLE_FOR_ESCAPE_HTML__ = {

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0