Skip to content

fix strict_base64 for shared strings#5985

Merged
kares merged 1 commit intojruby:masterfrom
ahorek:strict_base64
Dec 3, 2019
Merged

fix strict_base64 for shared strings#5985
kares merged 1 commit intojruby:masterfrom
ahorek:strict_base64

Conversation

@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 28, 2019

it fails for shared strings if begin != 0

require 'base64'
url = "data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFob3kuanMiXSwibmFtZXMiOlsiaGVsbG8iLCJ3b3JsZCJdLCJtYXBwaW5ncyI6IkFBQU0sU0FBU0EsUUFDUCxTQUFTQyxJQUNQLE9BQU8sRUFHVCxPQUFPQSxJQUFVQSIsInNvdXJjZXNDb250ZW50IjpbIiAgICAgIGZ1bmN0aW9uIGhlbGxvICgpIHtcbiAgICAgICAgZnVuY3Rpb24gd29ybGQgKCkge1xuICAgICAgICAgIHJldHVybiAyO1xuICAgICAgICB9O1xuXG4gICAgICAgIHJldHVybiB3b3JsZCgpICsgd29ybGQoKTtcbiAgICAgIH07XG4iXX0="

base = url.split(",").last
Base64.strict_decode64(base)

refs #5961

@kares kares merged commit af24ff7 into jruby:master Dec 3, 2019
@kares kares added this to the JRuby 9.2.10.0 milestone Dec 3, 2019
@enebo
Copy link
Member

enebo commented Dec 3, 2019

@ahorek thanks for this fix. I noticed right before rubyconf something was not properly decoding CSRF tags but when I quickly looked we were decoding properly (which of course was because my new string was not shared and begin == 0). The number of times this lack of abstract has hurt us is a bloody affair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants