0

我们有在 REE 1.8.7p-358 上运行的小型 Sinatra 应用程序

NewRelic 报告了一些这样的问题:

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'

从 Rack 来源我看到它/\A(?:%[0-9a-fA-F]{2}|[^%])*\z/用于检测无效的 %-encoding:

raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/ =~ str

我想尝试在本地重现错误。我的问题是:什么字符串应该是导致正则表达式匹配器中的堆栈溢出,试图将它与/\A(?:%[0-9a-fA-F]{2}|[^%])*\z/

4

1 回答 1

-2

/\A(?:%[0-9a-fA-F]{2}|[^%])*\z/ 如果超过 1%,你的表情就会被甩掉。我一直在用Rubular测试它

于 2013-08-21T16:17:39.993 回答