如果标题的措辞不正确,我会道歉但我现在可以输出我想要的内容: -
$noescape = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($this->_queryText));
然后通过var转储以下内容: -
$noescape
现有功能的最终输出是: -
return $this->_queryText;
我需要修改_queryText
以使用$noescape
或包含上面的preg_replace
...
我不确定我是否可以按照以下方式对return $this->_queryText;
进行语法修改: -
return $this->preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($this->_queryText));
或
return $noescape($this->_queryText);
或者我是否需要修改函数的另一部分(下面的整个函数): -
/**
* Retrieve search query text
*
* @return string
*/
public function getQueryText()
{
if (!isset($this->_queryText)) {
$this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName());
if ($this->_queryText === null) {
$this->_queryText = '';
} else {
/* @var $stringHelper Mage_Core_Helper_String */
$stringHelper = Mage::helper('core/string');
$this->_queryText = is_array($this->_queryText) ? ''
: $stringHelper->cleanString(trim($this->_queryText));
$noescape = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($this->_queryText));
echo '<span style="display: none;">';
echo '<pre>';
var_dump (
//$this->rawurldecode($this->getQueryText())
$noescape
);
echo '</pre>';
echo '</span>';
$maxQueryLength = $this->getMaxQueryLength();
if ($maxQueryLength !== '' && $stringHelper->strlen($this->_queryText) > $maxQueryLength) {
$this->_queryText = $stringHelper->substr($this->_queryText, 0, $maxQueryLength);
$this->_isMaxLength = true;
}
}
}
return $this->_queryText;
//return $this->preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($this->_queryText));
//return $noescape($this->_queryText);
}
希望有道理......
答案 0 :(得分:0)
好的,其他人已经设法为我指出了这一点......
return $this->_queryText = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($this->_queryText));
完美地工作。