Skip to content

Commit d28fb4c

Browse files
committed
Fix php/base64 encoder
Having things like `'abcde.chr(43).fgh'` doesn't fly, but `'abcde'.chr(43).'fgh'` does.
1 parent 233f6dc commit d28fb4c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modules/encoders/php/base64.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ def encode_block(state, buf)
7676
# Plus characters ('+') in a uri are converted to spaces, so replace
7777
# them with something that PHP will turn into a plus. Slashes cause
7878
# parse errors on the server side, so do the same for them.
79-
b64.gsub!('+', '.chr(43).')
80-
b64.gsub!('/', '.chr(47).')
79+
b64.gsub!('+', "#{quote}.chr(43).#{quote}")
80+
b64.gsub!('/', "#{quote}.chr(47).#{quote}")
8181

8282
state.badchars.each_byte do |byte|
8383
# Last ditch effort, if any of the normal characters used by base64
8484
# are badchars, try to replace them with something that will become
8585
# the appropriate thing on the other side.
8686
if b64.include?(byte.chr)
87-
b64.gsub!(byte.chr, ".chr(#{byte}).")
87+
b64.gsub!(byte.chr, "#{quote}.chr(#{byte}).#{quote}")
8888
end
8989
end
9090

0 commit comments

Comments
 (0)