lib/plezi/server/helpers/http.rb in plezi-0.7.5 vs lib/plezi/server/helpers/http.rb in plezi-0.7.6
- old
+ new
@@ -97,12 +97,12 @@
when :uri, :url
object.gsub!(/\%[0-9a-fA-F][0-9a-fA-F]/) {|m| m[1..2].to_i(16).chr}
when :html
object.gsub!(/&/i, '&')
object.gsub!(/"/i, '"')
- object.gsub!(/>/i, ">")
- object.gsub!(/</i, "<")
+ object.gsub!(/>/i, '>')
+ object.gsub!(/</i, '<')
when :utf8
else
end
@@ -124,23 +124,23 @@
elsif object.is_a?(Array)
object.each {|v| encode v, decode_method}
elsif object.is_a?(String)
case decode_method
when :uri, :url, :form
- object.force_encoding "binary"
+ object.force_encoding 'binary'
object.gsub!(/[^a-zA-Z0-9\*\.\_\-]/) {|m| m.ord <= 16 ? "%0#{m.ord.to_s(16)}" : "%#{m.ord.to_s(16)}"}
when :html
- object.gsub!('&', "&")
- object.gsub!('"', """)
- object.gsub!(">", ">")
- object.gsub!("<", "<")
- object.gsub!(/[^\sa-zA-Z\d\&\;]/) {|m| "&#%04d;" % m.unpack('U')[0] }
+ object.gsub!('&', '&')
+ object.gsub!('"', '"')
+ object.gsub!('>', '>')
+ object.gsub!('<', '<')
+ object.gsub!(/[^\sa-zA-Z\d\&\;]/) {|m| '&#%04d;' % m.unpack('U')[0] }
# object.gsub!(/[^\s]/) {|m| "&#%04d;" % m.unpack('U')[0] }
- object.force_encoding "binary"
+ object.force_encoding 'binary'
when :utf8
- object.gsub!(/[^\sa-zA-Z\d]/) {|m| "&#%04d;" % m.unpack('U')[0] }
- object.force_encoding "binary"
+ object.gsub!(/[^\sa-zA-Z\d]/) {|m| '&#%04d;' % m.unpack('U')[0] }
+ object.force_encoding 'binary'
else
end
return object
elsif object.is_a?(Symbol)
@@ -161,10 +161,10 @@
end
# re-encodes a string into UTF-8
def make_utf8!(string, encoding= 'utf-8')
return false unless string
- string.force_encoding("binary").encode!(encoding, "binary", invalid: :replace, undef: :replace, replace: '') unless string.force_encoding(encoding).valid_encoding?
+ string.force_encoding('binary').encode!(encoding, 'binary', invalid: :replace, undef: :replace, replace: '') unless string.force_encoding(encoding).valid_encoding?
string
end
# Changes String to a Ruby Object, if it's a special string
def rubyfy!(string)