summaryrefslogtreecommitdiff
path: root/lib/uri/common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r--lib/uri/common.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 1da9f47647..8c657cdee7 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -899,7 +899,9 @@ module URI
# See URI.encode_www_form_component, URI.decode_www_form
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
raise ArgumentError, "invalid %-encoding (#{str})" unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str
- str.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
+ str.dup.force_encoding("ASCII-8BIT") \
+ .gsub(/\+|%\h\h/, TBLDECWWWCOMP_) \
+ .force_encoding(enc)
end
# Generate URL-encoded form data from given +enum+.