Issue Bug Closed

#17830does not check sword size when type=20 (fix included)

Jonas Felix 11/21/07, 19:04 updated 05/14/13, 10:44

Description

If you selec type=20, it does not check for the size of the sword, so that all search index entries are found.

That’s especialy a problem when you set _DEFAULT_PI_VARS.type=20, because then the indexed_search shows results even if you did not submit the search form (just by opening a page with the search plugin on)

You have to fix the problem within the following function (that’s the fixed version):

————————————
function getSearchWords($defOp) {
// Shorten search-word string to max 200 bytes (does NOT take multibyte charsets into account – but never mind, shortening the string here is only a run-away feature!)
$inSW = substr($this->piVars[‘sword’],0,200);

// Convert to UTF-8 + conv. entities (was also converted during indexing!)
$inSW = $GLOBALS[‘TSFE’]->csConvObj->utf8_encode($inSW, $GLOBALS[‘TSFE’]->metaCharset);
$inSW = $GLOBALS[‘TSFE’]->csConvObj->entities_to_utf8($inSW,TRUE);
if ($hookObj = &$this->hookRequest(‘getSearchWords’))    {
return $hookObj->getSearchWords_splitSWords($inSW, $defOp);
} else {
    if ($this->piVars[‘type’]==20 && strlen($inSW) > 1)    {
return array(array(‘sword’=>trim($inSW), ‘oper’=>‘AND’));
} else {
$search = t3lib_div::makeInstance(‘tslib_search’);
$search->default_operator = $defOp==1 ? ‘OR’ : ‘AND’;
$search->operator_translate_table = $this->operator_translate_table;
$search->register_and_explode_search_string($inSW);
        if (is_array($search->sword_array))    {
return $this->procSearchWordsByLexer($search->sword_array);
}
}
}
}

———————————-

by changing this:

if ($this->piVars[‘type’]==20)    {
return array(array(‘sword’=>trim($inSW), ‘oper’=>‘AND’));
} else {

to that:

if ($this->piVars[‘type’]==20 && strlen($inSW) > 0)    {
return array(array(‘sword’=>trim($inSW), ‘oper’=>‘AND’));
} else {
(issue imported from #M6790)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.