From 1115703b7ccb6280a240454ab996128938c53b59 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Fri, 12 Apr 2019 22:29:34 +0200 Subject: [PATCH] Drop Ruby 1.8 compat code --- .../lib/rack/protection/path_traversal.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/rack-protection/lib/rack/protection/path_traversal.rb b/rack-protection/lib/rack/protection/path_traversal.rb index a6ca87f0..4e8c94ca 100644 --- a/rack-protection/lib/rack/protection/path_traversal.rb +++ b/rack-protection/lib/rack/protection/path_traversal.rb @@ -19,18 +19,10 @@ module Rack end def cleanup(path) - if path.respond_to?(:encoding) - # Ruby 1.9+ M17N - encoding = path.encoding - dot = '.'.encode(encoding) - slash = '/'.encode(encoding) - backslash = '\\'.encode(encoding) - else - # Ruby 1.8 - dot = '.' - slash = '/' - backslash = '\\' - end + encoding = path.encoding + dot = '.'.encode(encoding) + slash = '/'.encode(encoding) + backslash = '\\'.encode(encoding) parts = [] unescaped = path.gsub(/%2e/i, dot).gsub(/%2f/i, slash).gsub(/%5c/i, backslash)