postnl/postnl-magento1-End-of-life

broken deliveryoptions json params for cities with an apostrophe in the name

Closed this issue · 5 comments

When for example loading the nearest pickup points from 's Hertogenbosch the javascript gets screwed due to the apostrophe in the cities name. See Git Diff below for a fix:

From cfbb201311902e6e05c1a9f39ae392b275a95918 Mon Sep 17 00:00:00 2001
From: Peter Keijsers <peter.keijsers@experius.nl>
Date: Tue, 4 Jul 2017 13:31:56 +0000
Subject: [PATCH] [BUGFIX] Escape cities starting with an apostrophe in the
 name

---
 .../onestepcheckout/deliveryoptions.phtml          | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/app/design/frontend/base/default/template/TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml b/app/design/frontend/base/default/template/TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml
index 9f3bd17..6b54cec 100644
--- a/app/design/frontend/base/default/template/TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml
+++ b/app/design/frontend/base/default/template/TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml
@@ -330,23 +330,23 @@
         var postnlDebugMode = <?php echo $this->isDebugEnabled() ? 'true' : 'false'; ?>;
 
         params = {
-            saveUrl            : '<?php echo $this->getUrl('postnl/deliveryOptions/saveSelectedOption', array('_secure' => true)) ?>',
-            timeframesUrl      : '<?php echo $this->getUrl('postnl/deliveryOptions/getDeliveryTimeframes', array('_secure' => true)) ?>',
-            locationsUrl       : '<?php echo $this->getUrl('postnl/deliveryOptions/getNearestLocations', array('_secure' => true)) ?>',
-            locationsInAreaUrl : '<?php echo $this->getUrl('postnl/deliveryOptions/getLocationsInArea', array('_secure' => true)) ?>',
+            saveUrl            : "<?php echo $this->getUrl('postnl/deliveryOptions/saveSelectedOption', array('_secure' => true)) ?>",
+            timeframesUrl      : "<?php echo $this->getUrl('postnl/deliveryOptions/getDeliveryTimeframes', array('_secure' => true)) ?>",
+            locationsUrl       : "<?php echo $this->getUrl('postnl/deliveryOptions/getNearestLocations', array('_secure' => true)) ?>",
+            locationsInAreaUrl : "<?php echo $this->getUrl('postnl/deliveryOptions/getLocationsInArea', array('_secure' => true)) ?>",
             postcode           : postcode,
             housenumber        : housenumber,
             street             : street,
-            country            : '<?php echo $this->escapeHtml($_country); ?>',
-            city               : '<?php echo $this->escapeHtml($_city); ?>',
-            deliveryDate       : '<?php echo $this->escapeJavascriptHtml($_deliveryDate); ?>',
-            pickupDate         : '<?php echo $this->escapeJavascriptHtml($_pickupDate); ?>',
+            country            : "<?php echo $this->escapeHtml($_country); ?>",
+            city               : "<?php echo $this->escapeHtml($_city); ?>",
+            deliveryDate       : "<?php echo $this->escapeJavascriptHtml($_deliveryDate); ?>",
+            pickupDate         : "<?php echo $this->escapeJavascriptHtml($_pickupDate); ?>",
             imageBaseUrl       : baseUrl,
             fullAddress        : fullAddress,
             cutOffTimes        : {
-                weekday: '<?php echo $_weekdayCutOffTime; ?>',
-                sunday: '<?php echo $_sundayCutOffTime; ?>',
-                sameday: '<?php echo $_sameDayCutOffTime; ?>'
+                weekday: "<?php echo $_weekdayCutOffTime; ?>",
+                sunday: "<?php echo $_sundayCutOffTime; ?>",
+                sameday: "<?php echo $_sameDayCutOffTime; ?>"
             }
         };
 
-- 
2.7.4.1.g5468f9e

Hi Keijsers,

Thank you for sending in this issue. Did you encounter this problem with the latest version of our PostNL extension?

I am asking this because we fixed a lot of issues in the delivery options regarding to the apostrophe in version 1.12.2 for the core checkout and 1.12.3 for OSC and GoMage checkout.

Hi Dennis

I found it in 1.12.2. But looking at version 1.12.3 of the same file (app/design/frontend/base/default/template/TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml) I see the single apostrophe still there around line 333. I don't know if the problem is fixed somewhere else in the code. I haven't tried 1.12.3 yet for this specific problem.

I looked into it for you. This was indeed fixed in 1.12.3 in a different way. The following is the commit that contains a fix of the issue:
04af3c3

Hi Dennis

I see. Thanks for this fix. I'll update the module. Sorry for this false issue then :)

No problem at all :)