Issue #5322 has been reported by Rasmus Rønn Nielsen. ---------------------------------------- Bug #5322: URI.decode_www_form_component very slow with certain inputs http://redmine.ruby-lang.org/issues/5322 Author: Rasmus Rønn Nielsen Status: Open Priority: Normal Assignee: Category: Target version: 1.9.2 ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1] 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 `<main>' 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] -- http://redmine.ruby-lang.org