From e961bb6f26a368c01cb4fd5058574a74e31a036a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 1 Dec 2008 19:29:45 +0000 Subject: [PATCH] forward port Product JSON collateral wide character fix --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Sku/Product.pm | 4 ++-- t/Asset/Sku/ProductCollateral.t | 13 +++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 08f821046..5501ca4d7 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -15,6 +15,7 @@ - fixed #9155: purpose of "headblock" duplicates "extra head tags" - fixed: Improve Thingy navigation. - fixed #9126: UserList is completely broken in 7.6.4 (Yung Han Khoe) + - fixed #9177: Wide-characters break product varients 7.6.4 - Survey now will show progress and time limit. diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 320f2c635..2860dde9e 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -260,7 +260,7 @@ sub getAllCollateral { my $json = $self->get($tableName); my $table; if ($json) { - $table = decode_json($json); + $table = from_json($json); } else { $table = []; @@ -785,7 +785,7 @@ The name of the table to insert the data. sub setAllCollateral { my $self = shift; my $tableName = shift; - my $json = encode_json($self->{_collateral}->{$tableName}); + my $json = to_json($self->{_collateral}->{$tableName}); $self->update({ $tableName => $json }); return; } diff --git a/t/Asset/Sku/ProductCollateral.t b/t/Asset/Sku/ProductCollateral.t index 3ffcba690..2a3dd674f 100644 --- a/t/Asset/Sku/ProductCollateral.t +++ b/t/Asset/Sku/ProductCollateral.t @@ -19,6 +19,7 @@ use lib "$FindBin::Bin/../../lib"; use Test::More; use Test::Deep; +use Test::Exception; use JSON; use Data::Dumper; @@ -35,7 +36,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 33; # Increment this number for each test you create +plan tests => 34; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here @@ -291,16 +292,20 @@ is( $product5->getCollateral('variantsJSON', 'vid', $newVid)->{check}, 'no leaks $product5->purge; +##Handle wide characters + my $product6 = $root->addChild({ className => "WebGUI::Asset::Sku::Product", title => "Wide character attempt", }); -$newVid = $product6->setCollateral('variantsJSON', 'vid', 'new', { wideChar => q!“I hope this has a smart quote in it.”! +$newVid = $product6->setCollateral('variantsJSON', 'vid', 'new', { wideChar => qq!on 16\x{201d} hand-crocheted Cord! , vid => 'new' }); -use Data::Dumper; -diag Dumper $product6->getCollateral('variantsJSON', 'vid', $newVid); +my $product6a = WebGUI::Asset->newByDynamicClass($session, $product6->getId); +lives_ok { $product6a->getAllCollateral('variantsJSON', 'vid', $newVid); }, 'Product collateral handles wide-character encodings okay'; + +$product6->purge; #---------------------------------------------------------------------------- # Cleanup