Created
January 24, 2012 01:48
-
-
Save tenderlove/1667280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/uri/common.rb b/lib/uri/common.rb | |
index 90e6559..e2d7ff8 100644 | |
--- a/lib/uri/common.rb | |
+++ b/lib/uri/common.rb | |
@@ -849,6 +849,15 @@ module URI | |
end | |
TBLENCWWWCOMP_ = {} # :nodoc: | |
+ | |
+ tbl = TBLENCWWWCOMP_ | |
+ if tbl.empty? | |
+ 256.times do |i| | |
+ tbl[i.chr] = '%%%02X' % i | |
+ end | |
+ tbl[' '] = '+' | |
+ end | |
+ | |
TBLDECWWWCOMP_ = {} # :nodoc: | |
HTML5ASCIIINCOMPAT = [Encoding::UTF_7, Encoding::UTF_16BE, Encoding::UTF_16LE, | |
Encoding::UTF_32BE, Encoding::UTF_32LE] # :nodoc: | |
@@ -863,18 +872,6 @@ module URI | |
# | |
# See URI.decode_www_form_component, URI.encode_www_form | |
def self.encode_www_form_component(str) | |
- if TBLENCWWWCOMP_.empty? | |
- tbl = {} | |
- 256.times do |i| | |
- tbl[i.chr] = '%%%02X' % i | |
- end | |
- tbl[' '] = '+' | |
- begin | |
- TBLENCWWWCOMP_.replace(tbl) | |
- TBLENCWWWCOMP_.freeze | |
- rescue | |
- end | |
- end | |
str = str.to_s | |
if HTML5ASCIIINCOMPAT.include?(str.encoding) | |
str = str.encode(Encoding::UTF_8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment