2

I am testing CE ver 1.9.1.1 and discover the error. To replicate, go to any sales order page in admin and enter "80%" in the comment history, click the button Submit Comment. So far so good, then hit F5 to refresh the page and you'll see the error:

Warning: vsprintf(): Too few arguments in .../app/code/core/Mage/Adminhtml/Helper/Sales.php on line 133

Here's the function that contains line 133:

public function escapeHtmlWithLinks($data, $allowedTags = null)
{
    if (is_string($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
        $links = array();
        $i = 1;
        $regexp = '@(<a[^>]*>(?:[^<]|<[^/]|</[^a]|</a[^>])*</a>)@';
        while (preg_match($regexp, $data, $matches)) {
            $links[] = $matches[1];
            $data = str_replace($matches[1], '%' . $i . '$s', $data);
            ++$i;
        }
        $data = Mage::helper('core')->escapeHtml($data, $allowedTags);
        return vsprintf($data, $links);
    }
    return Mage::helper('core')->escapeHtml($data, $allowedTags);
}

Is this a bug? Is there a workaround?

2
  • This has been reported here
    – kiatng
    Commented May 8, 2015 at 1:13
  • Also here and will be fixed in the upcoming CE 1.9.2.
    – kiatng
    Commented May 8, 2015 at 1:24

1 Answer 1

2

Percent sign used for conversion specification in vsprintf. So, you just need to escape it.

update

if (is_string($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {

to

if (is_string($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
        $data = str_replace('%', '%%', $data);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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