diff options
author | Stormwind <stormwind@stormwinds-page.de> | 2012-12-23 12:23:14 +0100 |
---|---|---|
committer | Stormwind <stormwind@stormwinds-page.de> | 2012-12-23 12:23:14 +0100 |
commit | 65b1d3a1dab95be5ac82d9e0c6a75b743bc89ce0 (patch) | |
tree | e41fd0ab8deedbf77187f92448f453a1e8425ebc /lib | |
parent | ca2273e700e65b3d035f47042314ebcbfc9fd220 (diff) |
Remove 1.8 fixes
The fixes for Ruby 1.8 will take place in a seperate gem. So I remove
all the changes here.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zero.rb | 2 | ||||
-rw-r--r-- | lib/zero/patches/uri.rb | 90 |
2 files changed, 0 insertions, 92 deletions
diff --git a/lib/zero.rb b/lib/zero.rb index c9909a7..baf876c 100644 --- a/lib/zero.rb +++ b/lib/zero.rb @@ -1,5 +1,3 @@ -require 'zero/patches/uri' - module Zero require 'zero/controller' require 'zero/router' diff --git a/lib/zero/patches/uri.rb b/lib/zero/patches/uri.rb deleted file mode 100644 index 0b64abb..0000000 --- a/lib/zero/patches/uri.rb +++ /dev/null @@ -1,90 +0,0 @@ -module URI - - # Gets a query string and splits it into its key value pairs. - # If URI already supports this functionality (decode_www_form on Ruby 1.9+), - # it will use this. Else it will run an onw implementation, without any - # encoding functionality. - # - # @param [String] query The query string - # @return [Array] Parsed query - # - def self.parse_query_string(query) - # Call the original decode_www_form method on ruby 1.9+ - if URI::respond_to? 'decode_www_form' - return self.decode_www_form query - end - - # else split the query self - return self.decode_www_form_18 query - end - - # Own implementation of decode_www_form. - # Shall behave almost like the original method, but without any encoding - # stuff. - # - # @param [String] query The query string - # @return [Array] Parsed query - # - def self.decode_www_form_18(query) - return [] if query.empty? - - unless query.match /^[^#=;&]*=[^#=;&]*([;&][^#=;&]*=[^#=;&]*)*$/ - raise ArgumentError, - "invalid data of application/x-www-form-urlencoded (#{query})" - end - parsed = [] - # breakes the string at & and ; - query.split(/[&;]/).each do |query_part| - # breakes the string parts at = - key, value = query_part.split('=') - - # make an empty string out of value, if it's nil - value = '' if value.nil? - # append the key value pair on the result array - parsed << [ - decode_www_form_component_18(key), - decode_www_form_component_18(value) - ] - end - # return result array - return parsed - end - - TBLDECWWWCOMP18_ = {} - - # Own implementation of decode_www_form_component. - # Shall behave almost like the original method, but without any encoding - # stuff. - # - # @param [String] string - # @return [String] - # - def self.decode_www_form_component_18(string) - # Fill table for URI special chars - if TBLDECWWWCOMP18_.empty? - tbl = {} - 256.times do |i| - h, l = i>>4, i&15 - tbl['%%%X%X' % [h, l]] = i.chr - tbl['%%%x%X' % [h, l]] = i.chr - tbl['%%%X%x' % [h, l]] = i.chr - tbl['%%%x%x' % [h, l]] = i.chr - end - tbl['+'] = ' ' - begin - TBLDECWWWCOMP18_.replace(tbl) - TBLDECWWWCOMP18_.freeze - rescue - end - end - # unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str - # raise ArgumentError, "invalid %-encoding (#{str})" - # end - - # Replace URI special chars - string.gsub(/\+|%[a-zA-Z0-9]{2}/) do |sub_string| - TBLDECWWWCOMP18_[sub_string] - end - end - -end |