From 6738c7b9951e1844c9baecbe5733e43305d82a32 Mon Sep 17 00:00:00 2001 From: Hongli Lai Date: Fri, 6 Dec 2024 15:54:44 +0100 Subject: [PATCH] Fixes compatibility with Ruby apps whose Gemfile.lock depends on base64 --- CHANGELOG | 1 + .../phusion_passenger/utils.rb | 20 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3672ced866..a3aff0cc81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ Release 6.0.24 (Not yet released) * [Enterprise] Fix a memory corruption-related crash that could occur during rolling restarting. * [Ubuntu] Add packages for Ubuntu 24.10 "oracular". * [Ruby] Specify rackup version to avoid broken 1.0 gem. Closes GH-2559. + * Fixes compatibility with Ruby apps whose Gemfile.lock depends on base64. * Upgrades Boost from 1.85 -> 1.86. * Updated various library versions used in precompiled binaries (used for e.g. gem installs): - ccache 4.10.1 -> 4.10.2 diff --git a/src/ruby_supportlib/phusion_passenger/utils.rb b/src/ruby_supportlib/phusion_passenger/utils.rb index 14ae6e1a69..1556e6b3fa 100644 --- a/src/ruby_supportlib/phusion_passenger/utils.rb +++ b/src/ruby_supportlib/phusion_passenger/utils.rb @@ -23,8 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require 'base64' - module PhusionPassenger # Utility functions. @@ -182,19 +180,11 @@ def install_options_as_ivars(object, options, *keys) end end - if Base64.respond_to?(:strict_encode64) - def base64(data) - Base64.strict_encode64(data) - end - else - # Base64-encodes the given data. Newlines are removed. - # This is like `Base64.strict_encode64`, but also works - # on Ruby 1.8 which doesn't have that method. - def base64(data) - result = Base64.encode64(data) - result.delete!("\n") - result - end + # Returns a base64 encoded string without line breaks and padding. + # Like Base64.strict_encode64, but without a dependency on the + # 'base64' library/gem. + def base64(data) + [data].pack("m0") end # Returns a string which reports the backtraces for all threads,