Skip to content

Commit

Permalink
Fix problem with long part context codes. See http://stackoverflow.co…
Browse files Browse the repository at this point in the history
  • Loading branch information
iox committed Aug 6, 2012
1 parent 288a70e commit d09a3f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dryml/lib/dryml/part_context.rb
Expand Up @@ -56,7 +56,9 @@ def initialize
def marshal(session)
context = [@part_name, @this_id, @locals]
context << form_field_path if form_field_path
data = Base64.encode64(Marshal.dump(context)).strip
# http://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby
# data = Base64.encode64(Marshal.dump(context)).strip
data = Base64.strict_encode64(Marshal.dump(context)).strip
digest = generate_digest(data, session)
"#{data}--#{digest}"
end
Expand All @@ -65,7 +67,6 @@ def marshal(session)
# Unmarshal part context to a hash and verify its integrity.
def unmarshal(client_store, page_this, session)
data, digest = CGI.unescape(client_store).strip.split('--')

raise TamperedWithPartContext unless digest == generate_digest(data, session)

context = Marshal.load(Base64.decode64(data))
Expand Down

0 comments on commit d09a3f3

Please sign in to comment.