rails/rails — pull request #14081 by rajcybage (2014-02-17 10:41:46+00:00)
Title: Message verifier now given an option to user to chooseto generate  url s...

...afe data

https://github.com/rails/rails/issues/14070

Fix this issue

We're using ActiveSupport::MessageVerifier to generate an auto-unsubscribe link. Something that we found awkward is that some tokens contains slash ('/') , this cause that unsubscribe route needs a globbing to work.

u.unsubscription_token
=> "BAhpA/5gAQ==--ebb79a495452ba2bdc0335d45b921c238a19eccc"

# http://.../unsubscribe/BAhpA/5gAQ==--ebb79a495452ba2bdc0335d45b921c238a19eccc

# routes.rb
get '/newsletter/unsubscribe/*signature' => 'newsletters#unsubscribe'

the slash is generated in message_verifier.rb#L47

data = ::Base64.strict_encode64(Marshal.dump(90366))
=> "BAhpA/5gAQ=="

so we are wondering shouldn't ActiveSupport::MessageVerifier.new(secret_token).generate(user.id) generate a token without slash? is ok if we add something to filter slash symbol in message_verifier.rb#L47 ???