Bug #5322
closedURI.decode_www_form_component very slow with certain inputs
Description
When calling the following I get what I'd expect. An error.
URI.decode_www_form_component("aaaaaaaaaaaaaaaaaaaa%")
Here's the IRB output:
ruby-1.9.2-p290 :003 > URI.decode_www_form_component("aaaaaaaaaaaaaaaaaaaa%")
ArgumentError: invalid %-encoding (aaaaaaaaaaaaaaaaaaaa%)
from /Users/rasmus/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:778:in decode_www_form_component' from (irb):3 rom /Users/rasmus/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
'
But as I add more characters to the string, the execution becomes much much slower. I would expect it to be a lot faster than it is.
URI.decode_www_form_component("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%")
Add more characters and the call would take hours, if not days.
Related blog post: http://rrn.dk/running-ruby-process-callstack
I've reproduced this bug on these rubies:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Updated by regularfry (Alex Young) over 13 years ago
Looks like a duplicate of #5149 to me...
Updated by naruse (Yui NARUSE) over 13 years ago
- Status changed from Open to Closed