We have small Sinatra application which runs on REE 1.8.7p-358
NewRelic reports some issues like this:
RegexpError: Stack overflow in regexp matcher: /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/
.../gems/rack-1.4.1/lib/rack/backports/uri/common_18.rb: 67:in `decode_www_form_component'
.../gems/rack-1.4.1/lib/rack/utils.rb: 43:in `unescape'
.../gems/rack-1.4.1/lib/rack/utils.rb: 88:in `parse_nested_query'
.../gems/rack-1.4.1/lib/rack/utils.rb: 88:in `map'
.../gems/rack-1.4.1/lib/rack/utils.rb: 88:in `parse_nested_query'
.../gems/rack-1.4.1/lib/rack/utils.rb: 87:in `each'
.../gems/rack-1.4.1/lib/rack/utils.rb: 87:in `parse_nested_query'
.../gems/rack-1.4.1/lib/rack/request.rb: 334:in `parse_query'
.../gems/rack-1.4.1/lib/rack/request.rb: 209:in `POST'
.../gems/rack-1.4.1/lib/rack/request.rb: 221:in `params'
.../gems/sinatra-1.2.6/lib/sinatra/base.rb: 638:in `call!'
.../gems/sinatra-1.2.6/lib/sinatra/base.rb: 629:in `call'
From Rack sources I see that it uses /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/
is used to detect invalid %-encoding:
raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/ =~ str
I'd like to try to reproduce the error locally.
And my question is: what string should be that to cause stack overflow in regexp matcher on attempt to compare it with /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/