From d28fb4cbb61fe01e3a2036692a3ea6de5f5527e6 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 9 Aug 2024 12:07:39 -0700 Subject: [PATCH] Fix php/base64 encoder Having things like `'abcde.chr(43).fgh'` doesn't fly, but `'abcde'.chr(43).'fgh'` does. --- modules/encoders/php/base64.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/encoders/php/base64.rb b/modules/encoders/php/base64.rb index 0af848c6fbb7..f9cc79f542af 100644 --- a/modules/encoders/php/base64.rb +++ b/modules/encoders/php/base64.rb @@ -76,15 +76,15 @@ def encode_block(state, buf) # Plus characters ('+') in a uri are converted to spaces, so replace # them with something that PHP will turn into a plus. Slashes cause # parse errors on the server side, so do the same for them. - b64.gsub!('+', '.chr(43).') - b64.gsub!('/', '.chr(47).') + b64.gsub!('+', "#{quote}.chr(43).#{quote}") + b64.gsub!('/', "#{quote}.chr(47).#{quote}") state.badchars.each_byte do |byte| # Last ditch effort, if any of the normal characters used by base64 # are badchars, try to replace them with something that will become # the appropriate thing on the other side. if b64.include?(byte.chr) - b64.gsub!(byte.chr, ".chr(#{byte}).") + b64.gsub!(byte.chr, "#{quote}.chr(#{byte}).#{quote}") end end