diff --git a/ChangeLog b/ChangeLog index f78b4c0445..b241b38994 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Aug 24 12:15:12 2008 NARUSE, Yui + + * lib/net/http.rb (Net::HTTP#urlencode): str[0] returns char in 1.9. + Patch by Junegunn Choi [ruby-core:18368] + Sun Aug 24 12:02:39 2008 Tanaka Akira * transcode.c (rb_econv_open): return NULL on error. diff --git a/lib/net/http.rb b/lib/net/http.rb index b3ddee54e0..8e0c3b208f 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1526,7 +1526,7 @@ module Net #:nodoc: private :encode_kvpair def urlencode(str) - str.gsub(/[^a-zA-Z0-9_\.\-]/n) { sprintf('%%%02x', $&[0]) } + str.dup.force_encoding('ASCII-8BIT').gsub(/[^a-zA-Z0-9_\.\-]/){'%%%02x' % $&.ord} end private :urlencode