welcu/active_merchant_webpay — Issue #2: decode_www_form_component does not accept Webpay posts
Author: tiagomatos
Created: 2011-11-17 03:01:10+00:00
State: open

raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%\h\h|[^%]+)*\z/ =~ str (current 1.9.2)

http://www.ruby-doc.org/stdlib-1.9.2/libdoc/uri/rdoc/URI.html#method-c-decode_www_form_component

raise ArgumentError, "invalid %-encoding (#{str})" unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str (upcoming 1.9.3)

The current 1.9.2 version does not accept any POST from Webpay. If I remember correctly there was been some mess with security problem on 1.9.2 versions and they have restricted the regular expression.

The case with Webpay is it also needs to accep spaces, hence the fix:

raise ArgumentError, "invalid %-encoding (#{str})" unless /\A[^%]*(?:%\s?\h\h?[^%]*)*\z/ =~ str (fix for webpay)