1

If my search contains special chars like ü, ä they are encoded to %C3%BC for example.

The strange thing is, it does work correctly in one template, but not in another one.

Template 1: simple links ... works without encoding

<?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>
    <a href="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> class="active"<?php endif; ?>><span><span><?php echo $_limit ?></span></span></a>
<?php endforeach; ?>

Template 2: dropdown ... values are encoded

<select class="select--wd select--wd--sm"  onchange="setLocation(this.value)">
    <?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>
        <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif; ?>>
            <?php echo $_limit ?>
        </option>
    <?php endforeach; ?>
</select>
  • toolbar block is not rewritten, it's still Mage_Catalog_Block_Product_List_Toolbar.
  • it's the same server, just another website with another template

I've solved this with using urldecode(), but i still want to know where the different behavoir comes from.

5
  • db charsets perhaps?
    – jscar
    Jun 2, 2017 at 8:45
  • No, it's the same DB for all shops (normal multistore setup with 3 websites)
    – sv3n
    Jun 2, 2017 at 8:46
  • what happens if you htmlencode / decode the <option> value?
    – jscar
    Jun 2, 2017 at 8:49
  • What do you mean? Using urldecode works ... ?!?
    – sv3n
    Jun 2, 2017 at 8:56
  • excuse me sv3n - I'm not reading clearly this morning :(
    – jscar
    Jun 2, 2017 at 9:10

1 Answer 1

2

In template 2, when using a select element, the link is called with:

setLocation(this.value)

Since Magento 1.9.3.0, the implementation for this method in js/varien/js.js looks like that:

`window.location.href = encodeURI(url);`

The link is already encoded when it is inserted into the page, but encodeURI encodes it another time and therefore breaks the page.

See also Catalog Search Sorting Broken With Umlauts / Special Characters

0

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.