From d09a3f311d7ae8e06b33ee879d04dddf1affb7bf Mon Sep 17 00:00:00 2001 From: Ignacio Huerta Date: Mon, 6 Aug 2012 11:04:22 +0200 Subject: [PATCH] Fix problem with long part context codes. See http://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby --- dryml/lib/dryml/part_context.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dryml/lib/dryml/part_context.rb b/dryml/lib/dryml/part_context.rb index df5e30da9..46d18f9dc 100644 --- a/dryml/lib/dryml/part_context.rb +++ b/dryml/lib/dryml/part_context.rb @@ -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 @@ -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))