From ebe04fd538dd21cdc4819621902fc729a24c23bf Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 20 Sep 2023 15:25:48 -0700 Subject: [PATCH] Remove unnecessary branch in urlsafe_decode64 in column_encryption plugin Sequel always generates the base64 with = padding, so we don't need to check for unpadded base64 and adjust. --- lib/sequel/plugins/column_encryption.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/sequel/plugins/column_encryption.rb b/lib/sequel/plugins/column_encryption.rb index 70dae794f..e462940c9 100644 --- a/lib/sequel/plugins/column_encryption.rb +++ b/lib/sequel/plugins/column_encryption.rb @@ -490,13 +490,7 @@ def urlsafe_encode64(bin) end def urlsafe_decode64(str) - if str.length % 4 == 0 - str = str.tr("-_", "+/") - else - str = str.ljust((str.length + 3) & ~3, "=") - str.tr!("-_", "+/") - end - decode64(str) + decode64(str.tr("-_", "+/")) end # An array of strings, one for each configured encryption key, to find encypted values matching