Ticket #86 (closed defect: fixed)
TextSearch - Advanced search results reveal confidential info
| Reported by: | dartar | Owned by: | DotMG |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.1.6.2 |
| Component: | actions | Version: | 1.1.6.1 |
| Severity: | major | Keywords: | Search Text Security Confidential |
| Cc: |
Description (last modified by DotMG) (diff)
(reported by PolVazo - patch submitted by QualousHere) Results should be hidden or not shown if the user doesn't have read access to page IMHO
Solution
(based on 1.1.6.0)
- Changes in actions/textsearch.php
original:
if ($phrase = $_REQUEST["phrase"])
{
$phrase = stripslashes($phrase);
$results = $this->FullTextSearch($phrase);
print("<br />");
$total_results = count($results);
$match_str = $total_results <> 1 ? " matches" : " match";
print("Search results: <strong>".$total_results.$match_str."</strong> for <strong>$phrase</strong><br /><br />\n");
if ($results)
{
foreach ($results as $i => $page)
{
print(($i+1).". ".$this->Link($page["tag"])."<br />\n");
}
$phrase = urlencode($phrase);
print("<br />Not sure which page to choose?<br />Try the <a href=\"".$this->href("", "TextSearchExpanded", "phrase=$phrase")."\">Expanded Text Search</a> which shows surrounding text.");
}
}
modified:
if ($phrase = $_REQUEST["phrase"])
{
$phrase = preg_quote($this->htmlspecialchars_ent(stripslashes($phrase)), "/");
$results = $this->FullTextSearch($phrase);
$result_page_list = '';
$total_results = 0;
print("<br />");
if ($results)
{
foreach ($results as $i => $page)
{
if ($this->HasAccess("read",$page["tag"]))
{
$result_page_list .= ($i+1).". ".$this->Link($page["tag"])."<br />\n";
$total_results += 1;
}
}
$phrase = urlencode($phrase);
}
$match_str = $total_results <> 1 ? " matches" : " match";
print("Search results: <strong>".$total_results.$match_str."</strong> for <strong>$phrase</strong><br /><br />\n");
if ($total_results > 0)
{
print($result_page_list);
print("<br />Not sure which page to choose?<br />Try the <a href=\"".$this->href("", "TextSearchExpanded", "phrase=$phrase")."\">Expanded Text Search</a> which shows surrounding text.");
}
}
- Changes in actions/textsearchexpanded.php
original:
if (isset($_REQUEST["phrase"]) && $phrase = $_REQUEST["phrase"])
{
$phrase = stripslashes($phrase);
print("<br />");
$results = $this->FullTextSearch($phrase);
$match_str = count($results) <> 1 ? " matches" : " match";
print("Search results: <strong>".count($results).$match_str."</strong> for <strong>$phrase</strong><br /><br />\n");
$phrase = str_replace("\"", "", $phrase);
if ($results)
{
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
$STORE_FORMATING_AS_TEXT = 1;
foreach ($results as $i => $page)
{
//print(($i+1).". ".$this->Link($page["tag"])."<br />\n");
//print implode($this->LoadPage($page["tag"]));
//$matchString = preg_match("/(.{0,40}$phrase.{0,40})/",implode($this->LoadPage($page['tag'])));
/* display portion of the matching body and highlight
the search term */
preg_match("/(.{0,120}$phrase.{0,120})/is",$page['body'],$matchString);
$text = $this->htmlspecialchars_ent($matchString[0]);
// include("formatters/wakka.php");
$highlightMatch = preg_replace("/($phrase)/i","<font color=\"green\"><b>$1</b></font>",$text,-1);
$matchText = "<font color=\"gray\" size=\"-1\">...</font>$highlightMatch<font color=\"gray\" size=\"-1\">...</font>";
print "
<tr>
<td valign=\"top\" align=\"right\">
<!-- result number -->
<table>
<tr>
<td valign=\"top\" align=\"left\" bgcolor=\"#DDDDDD\">
<font color=\"white\" size=\"-3\">
".($i+1)."
</font>
</td>
</tr>
</table>
</td>
<!-- link -->
<td valign=\"top\">
".$this->Link($page["tag"])."
</td>
<!-- date of last update -->
<td valign=\"top\" align=\"right\">
<font color=\"gray\" size=\"-3\">
$page[time]
</font>
</td>
</tr>
<tr>
<td>
</td>
<td colspan=\"2\">
$matchText
</td>
</tr>
<tr>
<td>
</td>
</tr>
";
}
print "</table>";
}
}
modified:
if (isset($_REQUEST["phrase"]) && $phrase = $_REQUEST["phrase"])
{
$phrase = preg_quote($this->htmlspecialchars_ent(stripslashes($phrase)), "/");
print("<br />");
$results = $this->FullTextSearch($phrase);
$phrase = str_replace("\"", "", $phrase);
$result_page_list = '';
$total_results = 0;
if ($results)
{
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
$STORE_FORMATING_AS_TEXT = 1;
foreach ($results as $i => $page)
{
if ($this->HasAccess("read",$page["tag"]))
{
preg_match("/(.{0,120}$phrase.{0,120})/is",$page['body'],$matchString);
$text = $this->htmlspecialchars_ent($matchString[0]);
$highlightMatch = preg_replace("/($phrase)/i","<font color=\"green\"><b>$1</b></font>",$text,-1);
$matchText = "<font color=\"gray\" size=\"-1\">...</font>$highlightMatch<font color=\"gray\" size=\"-1\">...</font>";
$total_results += 1;
$result_page_list .= "
<tr>
<td valign=\"top\" align=\"right\">
<!-- result number -->
<table>
<tr>
<td valign=\"top\" align=\"left\" bgcolor=\"#DDDDDD\">
<font color=\"white\" size=\"-3\">
".($i+1)."
</font>
</td>
</tr>
</table>
</td>
<td valign=\"top\">
<!-- link -->
".$this->Link($page["tag"])."
</td>
<td valign=\"top\" align=\"right\">
<!-- date of last update -->
<font color=\"gray\" size=\"-3\">
$page[time]
</font>
</td>
</tr>
<tr>
<td> </td>
<td colspan=\"2\">$matchText</td>
</tr>
<tr>
<td> </td>
</tr>
";
}
}
$match_str = $total_results <> 1 ? " matches" : " match";
print("Search results: <strong>".$total_results.$match_str."</strong> for <strong>$phrase</strong><br /><br />\n");
if ($total_results > 0)
{
print($result_page_list);
print("</table>");
}
}
}
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
