From: Gaston Ramos Date: 2009-12-17T21:16:53+09:00 Subject: [ruby-core:27209] Re: [PATCH] fix CGI::escape to work with blocks, avoid dollar variables El Thu, 17 de Dec de 2009, a las 11:20:32AM +0900, NARUSE, Yui dijo: > > > > http://www.justskins.com/forums/bug-when-rerouting-string-gsub-with-a-block-using-1-a-52852.html > > > Even if you patch cgi.rb, you can use only matched string ($&) which is > passed as block parameter. > There are $~ (Regexp.last_match), $` (pre_match), $' (post_match) and $1, > $2, $3 and so on. > So your patch is fortunately adopted to cgi.rb, but not universal. > > So I'm against such a sectional patch. I couldn't understand your point, can you explain me wich is the problem? I can't read japanase. Please Can you give an example where my patch doesn't work? > > > > where Matz say "Then don't use ugly dollar variables" > > > When Matz say so? > That statement doesn't face up to real situation, described above. > dollar variables may be ugly but required. > > > > so, dollar variables are > > problematic in this case, I changed the dollar variables by a block > > argument > > variable and the problem was solved, I added 2 tests for CGI.escape and > > CGI.unescape that reproduce this "problem", If you agree with this patch I > > could > > do other new patch in order to avoid all dollar variables inside CGI lib. > > > > And there is a bug in ActiveSupport realted with this issue: > > > > https://rails.lighthouseapp.com/projects/8994/tickets/3475-activesupportmultibytecharsgsub-fails-while-stringgsub-works > > > > So current answer is "Don't change String#gsub when you controll all > things". > > See also this ticket (but this is in Japanese...) > http://redmine.ruby-lang.org/issues/show/546 > > -- > NARUSE, Yui > naruse@airemix.jp -- Gast�n Ramos