Skip to content

Commit

Permalink
SagePayForm: Updated sanitize to truncate description field. Fixes ac…
Browse files Browse the repository at this point in the history
  • Loading branch information
jnormore committed Jun 7, 2012
1 parent a3b77f7 commit 89ad9ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -107,6 +107,8 @@ def sanitize(key, value)
exact = /^[A-Z]{3}$/
when /State$/
exact = /^[A-Z]{2}$/
when 'Description'
value = value.truncate(100)
else
reject = /&+/
end
Expand Down
10 changes: 10 additions & 0 deletions test/unit/integrations/helpers/sage_pay_form_helper_test.rb
Expand Up @@ -110,6 +110,16 @@ def test_shipping_address_falls_back_to_billing_address
assert plain.include?('&DeliveryState=IL')
end
end

def test_description_should_truncate
description = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut la'
assert_equal 101, description.size
@helper.add_field('Description', description)

with_crypt_plaintext do |plain|
assert plain.include?('Description=Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt u...')
end
end

def test_set_shipping_address_wont_be_overridden_by_billing_address
@helper.billing_address(
Expand Down

0 comments on commit 89ad9ca

Please sign in to comment.