From: Geoffrey T. D. <da...@us...> - 2001-11-07 21:42:37
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv16342/lib Modified Files: Tag: release-1_2-branch search.php fullsearch.php Log Message: Fix SF bug #445108: Empty search string results in phpwiki error. Index: search.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/search.php,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -C2 -r1.3.2.1 -r1.3.2.2 *** search.php 2001/11/07 20:30:47 1.3.2.1 --- search.php 2001/11/07 21:42:34 1.3.2.2 *************** *** 15,25 **** // search matching pages - $query = InitTitleSearch($dbi, $search); $found = 0; ! while ($page = TitleSearchNextMatch($dbi, $query)) { ! $found++; ! $html .= LinkExistingWikiWord($page) . "<br>\n"; } ! $html .= "<hr noshade>\n" . sprintf(gettext ("%d pages match your query."), $found) --- 15,30 ---- // search matching pages $found = 0; ! if (strlen($search)) { ! $query = InitTitleSearch($dbi, $search); ! while ($page = TitleSearchNextMatch($dbi, $query)) { ! $found++; ! $html .= LinkExistingWikiWord($page) . "<br>\n"; ! } } ! else { ! $html .= gettext("(You entered an empty search string)") . "<br>\n"; ! } ! $html .= "<hr noshade>\n" . sprintf(gettext ("%d pages match your query."), $found) Index: fullsearch.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/fullsearch.php,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -r1.4.2.1 -r1.4.2.2 *** fullsearch.php 2001/11/07 20:30:47 1.4.2.1 --- fullsearch.php 2001/11/07 21:42:34 1.4.2.2 *************** *** 11,40 **** htmlspecialchars($full)) . "</B></P>\n<DL>\n"; - - // search matching pages - $query = InitFullSearch($dbi, $full); - - // quote regexp chars (space are treated as "or" operator) - $full = preg_replace("/\s+/", "|", preg_quote($full)); - $found = 0; $count = 0; ! while ($pagehash = FullSearchNextMatch($dbi, $query)) { ! $html .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n"; ! $count++; ! // print out all matching lines, highlighting the match ! for ($j = 0; $j < (count($pagehash["content"])); $j++) { if ($hits = preg_match_all(":$full:i", $pagehash["content"][$j], $dummy)) { ! $matched = preg_replace(":$full:i", ! "${FieldSeparator}OT\\0${FieldSeparator}CT", ! $pagehash["content"][$j]); ! $matched = htmlspecialchars($matched); ! $matched = str_replace("${FieldSeparator}OT", '<b>', $matched); ! $matched = str_replace("${FieldSeparator}CT", '</b>', $matched); ! $html .= "<dd><small>$matched</small></dd>\n"; ! $found += $hits; } ! } } --- 11,45 ---- htmlspecialchars($full)) . "</B></P>\n<DL>\n"; $found = 0; $count = 0; ! ! if (strlen($full)) { ! // search matching pages ! $query = InitFullSearch($dbi, $full); ! ! // quote regexp chars (space are treated as "or" operator) ! $full = preg_replace("/\s+/", "|", preg_quote($full)); ! ! while ($pagehash = FullSearchNextMatch($dbi, $query)) { ! $html .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n"; ! $count++; ! // print out all matching lines, highlighting the match ! for ($j = 0; $j < (count($pagehash["content"])); $j++) { if ($hits = preg_match_all(":$full:i", $pagehash["content"][$j], $dummy)) { ! $matched = preg_replace(":$full:i", ! "${FieldSeparator}OT\\0${FieldSeparator}CT", ! $pagehash["content"][$j]); ! $matched = htmlspecialchars($matched); ! $matched = str_replace("${FieldSeparator}OT", '<b>', $matched); ! $matched = str_replace("${FieldSeparator}CT", '</b>', $matched); ! $html .= "<dd><small>$matched</small></dd>\n"; ! $found += $hits; } ! } ! } ! } ! else { ! $html .= "<dd>" . gettext("(You entered an empty search string)") . "</dd>\n"; } |