[#39052] Fwd: [redmine4ruby-lang:253] [Bug #1914] ruby-1.9.1-p243 failed to build from source on aix 5.3 with gcc 4.2.0 — Yugui <yugui@...>

Redmine管理用プロジェクトに報告されてしまったので転送します。

12 messages 2009/08/09
[#39264] Re: Fwd: [redmine4ruby-lang:253] [Bug #1914] ruby-1.9.1-p243 failed to build from source on aix 5.3 with gcc 4.2.0 — Yutaka Kanemoto <kinpoco@...> 2009/09/08

金本と申します。

[#39107] [Bug #1952] cannot stop with Ctrl+C — Usaku NAKAMURA <redmine@...>

Bug #1952: cannot stop with Ctrl+C

14 messages 2009/08/18

[#39167] [Bug #2000] Change the license to "GPLv2+ or Ruby's original". — Mamoru Tasaka <redmine@...>

Bug #2000: Change the license to "GPLv2+ or Ruby's original".

11 messages 2009/08/26

[#39193] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Tanaka Akira <akr@...>

In article <200908281827.n7SIRbaX003476@ci.ruby-lang.org>,

16 messages 2009/08/29
[#39194] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Nobuyoshi Nakada <nobu@...> 2009/08/29

なかだです。

[#39195] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Tanaka Akira <akr@...> 2009/08/29

In article <4a988633.9553f10a.4496.483e@mx.google.com>,

[#39196] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Nobuyoshi Nakada <nobu@...> 2009/08/29

なかだです。

[#39197] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Tanaka Akira <akr@...> 2009/08/29

In article <4a989f76.1602be0a.3de4.1131@mx.google.com>,

[#39198] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Yukihiro Matsumoto <matz@...> 2009/08/29

まつもと ゆきひろです

[#39206] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. — Nobuyoshi Nakada <nobu@...> 2009/08/31

なかだです。

[ruby-dev:39184] URI.escape_component

From: "Akinori MUSHA" <knu@...>
Date: 2009-08-28 12:09:07 UTC
List: ruby-dev #39184
 JavaScript の escapeURIComponent() 相当の関数ってありましたっけ?
もしなければURIモジュールに追加するのはどうですか。

 ドキュメントの修正も混ざっていますが、以下がパッチです。

Index: lib/uri/common.rb
===================================================================
--- lib/uri/common.rb	(revision 24684)
+++ lib/uri/common.rb	(working copy)
@@ -70,6 +70,7 @@ module URI
     #
     #   * <tt>:ESCAPED</tt> (URI::PATTERN::ESCAPED in default)
     #   * <tt>:UNRESERVED</tt> (URI::PATTERN::UNRESERVED in default)
+    #   * <tt>:RESERVED</tt> (URI::PATTERN::RESERVED in default)
     #   * <tt>:DOMLABEL</tt> (URI::PATTERN::DOMLABEL in default)
     #   * <tt>:TOPLABEL</tt> (URI::PATTERN::TOPLABEL in default)
     #   * <tt>:HOSTNAME</tt> (URI::PATTERN::HOSTNAME in default)
@@ -226,6 +227,10 @@ module URI
       end.force_encoding(Encoding::US_ASCII)
     end

+    def escape_component(str, unsafe = @regexp[:NON_UNRESERVED])
+      escape(str, unsafe)
+    end
+
     def unescape(str, escaped = @regexp[:ESCAPED])
       str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)
     end
@@ -408,6 +413,7 @@ module URI
       # for URI::escape/unescape
       ret[:ESCAPED] = Regexp.new(pattern[:ESCAPED])
       ret[:UNSAFE]  = Regexp.new("[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]")
+      ret[:NON_UNRESERVED] = Regexp.new("[^#{pattern[:UNRESERVED]}]")

       # for Generic#initialize
       ret[:SCHEME]   = Regexp.new("^#{pattern[:SCHEME]}$")
@@ -476,10 +482,10 @@ module URI
     # == Args
     #
     # +str+::
-    #   String to replaces in.
+    #   String to escape.
     # +unsafe+::
     #   Regexp that matches all symbols that must be replaced with codes.
-    #   By default uses <tt>REGEXP::UNSAFE</tt>.
+    #   By default uses <tt>URI::UNSAFE</tt>.
     #   When this argument is a String, it represents a character set.
     #
     # == Description
@@ -529,6 +535,36 @@ module URI
       DEFAULT_PARSER.unescape(*arg)
     end
     alias decode unescape
+    #
+    # == Synopsis
+    #
+    #   URI.escape_component(str)
+    #
+    # == Args
+    #
+    # +str+::
+    #   String to escape.
+    # +unsafe+::
+    #   Regexp that matches all symbols that must be replaced with codes.
+    #   By default uses <tt>URI::NON_UNRESERVED</tt>.
+    #   When this argument is a String, it represents a character set.
+    #
+    # == Description
+    #
+    # This function is a version of escape() to escape a string for use
+    # in URI query components.
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://example.com/plot?q=" + URI.escape_component("y=2x"))
+    #   p uri
+    #   # => "http://example.com/plot?q=y%3D2x"
+    #
+    def escape_component(*arg)
+      DEFAULT_PARSER.escape_component(*arg)
+    end
   end

   extend Escape
Index: test/uri/test_common.rb
===================================================================
--- test/uri/test_common.rb	(revision 24684)
+++ test/uri/test_common.rb	(working copy)
@@ -49,6 +49,40 @@ class TestCommon < Test::Unit::TestCase
     assert_equal(expected, Kernel::URI("http://www.ruby-lang.org/"))
     assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") }
   end
+
+  RESERVED   = /\A[;\/\?:@&=\+\$,\[\]]\z/
+  UNRESERVED = /\A[\-_\.!~\*'\(\)A-Za-z0-9]\z/
+
+  def test_escape
+    unescaped = ''
+    escaped = ''
+    escaped_component = ''
+
+    (0x00..0x7f).map { |c|
+      ch = c.chr
+      esc = '%%%02X' % c
+
+      unescaped << ch
+
+      case ch
+      when UNRESERVED
+        escaped << ch
+        escaped_component << ch
+      when RESERVED
+        escaped << ch
+        escaped_component << esc
+      else
+        escaped << esc
+        escaped_component << esc
+      end
+    }
+
+    assert_equal(escaped, URI.escape(unescaped))
+    assert_equal(escaped_component, URI.escape_component(unescaped))
+
+    assert_equal(unescaped, URI.unescape(escaped))
+    assert_equal(unescaped, URI.unescape(escaped_component))
+  end
 end




--
Akinori MUSHA / http://akinori.org/

In This Thread

Prev Next