about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--examples/rails_app-2.3.4/config/initializers/ruby_19_compat.rb28
1 files changed, 7 insertions, 21 deletions
diff --git a/examples/rails_app-2.3.4/config/initializers/ruby_19_compat.rb b/examples/rails_app-2.3.4/config/initializers/ruby_19_compat.rb
index 82987f4..2cfab6c 100644
--- a/examples/rails_app-2.3.4/config/initializers/ruby_19_compat.rb
+++ b/examples/rails_app-2.3.4/config/initializers/ruby_19_compat.rb
@@ -12,29 +12,15 @@ module ActiveSupport
 
       # constant-time comparison algorithm to prevent timing attacks
       def secure_compare(a, b)
-        if a.respond_to?(:bytesize)
-          # > 1.8.6 friendly version
-          if a.bytesize == b.bytesize
-            result = 0
-            j = b.each_byte
-            a.each_byte { |i| result |= i ^ j.next }
-            result == 0
-          else
-            false
-          end
+        if a.bytesize == b.bytesize
+          result = 0
+          j = b.each_byte
+          a.each_byte { |i| result |= i ^ j.next }
+          result == 0
         else
-          # <= 1.8.6 friendly version
-          if a.size == b.size
-            result = 0
-            for i in 0..(a.length - 1)
-              result |= a[i] ^ b[i]
-            end
-            result == 0
-          else
-            false
-          end
+          false
         end
       end
 
   end
-end if Rails::VERSION::STRING == "2.3.4" && String.method_defined?(:bytesize)
+end if Rails::VERSION::STRING == "2.3.4" && "."[0] == "."