0

Fatal error: Call to undefined method Mage_Adminhtml_Helper_Sales::escapeHtmlWithLinks() in /app/design/frontend/base/default/template/mageworx/ordersedit/sales-order-view.phtml on line 78

Line 78:

<?php echo Mage::helper('adminhtml/sales')->htmlEscapeWithLinks($_historyItem->getComment(), array['b','br','strong','i','u', 'a']); ?>

Is this related with SUPEE-7405? I'm using Magento 1.7.0.2. This error is related to customer frontend when attaching documents to order. http://prntscr.com/n6wvmk

0

htmlEscapeWithLinks() doesn't exist in Mage\Adminhtml\Helper\Sales.php. I can find this method there escapeHtmlWithLinks(). Try replacing this and see if what happens. The patch does few changes but the method remains unaltered. So try replacing the method name and see what happens.

These are the changes the patch does

diff --git app/code/core/Mage/Adminhtml/Helper/Sales.php app/code/core/Mage/Adminhtml/Helper/Sales.php
index 72c43a8..da9af0f 100644
--- app/code/core/Mage/Adminhtml/Helper/Sales.php
+++ app/code/core/Mage/Adminhtml/Helper/Sales.php
@@ -120,19 +120,38 @@ class Mage_Adminhtml_Helper_Sales extends Mage_Core_Helper_Abstract
      */
     public function escapeHtmlWithLinks($data, $allowedTags = null)
     {
-        if (is_string($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
-            $links = array();
+        if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
+            $links = [];
             $i = 1;
             $data = str_replace('%', '%%', $data);
-            $regexp = '@(<a[^>]*>(?:[^<]|<[^/]|</[^a]|</a[^>])*</a>)@';
+            $regexp = "/<a\s[^>]*href\s*?=\s*?([\"\']??)([^\" >]*?)\\1[^>]*>(.*)<\/a>/siU";
             while (preg_match($regexp, $data, $matches)) {
-                $links[] = $matches[1];
-                $data = str_replace($matches[1], '%' . $i . '$s', $data);
+                //Revert the sprintf escaping
+                $url = str_replace('%%', '%', $matches[2]);
+                $text = str_replace('%%', '%', $matches[3]);
+                //Check for an valid url
+                if ($url) {
+                    $urlScheme = strtolower(parse_url($url, PHP_URL_SCHEME));
+                    if ($urlScheme !== 'http' && $urlScheme !== 'https') {
+                        $url = null;
+                    }
+                }
+                //Use hash tag as fallback
+                if (!$url) {
+                    $url = '#';
+                }
+                //Recreate a minimalistic secure a tag
+                $links[] = sprintf(
+                    '<a href="%s">%s</a>',
+                    htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false),
+                    parent::escapeHtml($text)
+                );
+                $data = str_replace($matches[0], '%' . $i . '$s', $data);
                 ++$i;
             }
-            $data = Mage::helper('core')->escapeHtml($data, $allowedTags);
+            $data = parent::escapeHtml($data, $allowedTags);
             return vsprintf($data, $links);
         }
-        return Mage::helper('core')->escapeHtml($data, $allowedTags);
+        return parent::escapeHtml($data, $allowedTags);
     }
-}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.