Project

General

Profile

Actions

Bug #5322

closed

URI.decode_www_form_component very slow with certain inputs

Added by rasmusrn (Rasmus Rønn Nielsen) over 13 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]
Backport:
[ruby-core:39544]

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]


Related issues 1 (0 open1 closed)

Is duplicate of Backport192 - Backport #5149: Specific combination of regexp and string causes 100% CPU and doesn't recoverRejectedyugui (Yuki Sonoda)Actions

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
Actions

Also available in: Atom PDF

Like0
Like0Like0