Skip to content

Commit

Permalink
Search non-ASCII data only in text columns (bug #3564415)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Sep 9, 2012
1 parent 66d537c commit 312075d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions adminer/include/adminer.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,12 @@ function selectSearchProcess($fields, $indexes) {
// find anywhere
$cols = array();
foreach ($fields as $name => $field) {
if (is_numeric($val["val"]) || !ereg('int|float|double|decimal|bit', $field["type"])) {
$is_text = ereg('char|text|enum|set', $field["type"]);
if ((is_numeric($val["val"]) || !ereg('int|float|double|decimal|bit', $field["type"]))
&& (!ereg("[\x80-\xFF]", $val["val"]) || $is_text)
) {
$name = idf_escape($name);
$cols[] = ($jush == "sql" && ereg('char|text|enum|set', $field["type"]) && !ereg('^utf8', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
$cols[] = ($jush == "sql" && $is_text && !ereg('^utf8', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
}
}
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
Expand Down
6 changes: 4 additions & 2 deletions adminer/include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,14 @@ function search_tables() {
$name = $adminer->tableName($table_status);
if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
$result = $connection->query("SELECT" . limit("1 FROM " . table($table), " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())), 1));
if ($result->fetch_row()) {
if (!$result || $result->fetch_row()) {
if (!$found) {
echo "<ul>\n";
$found = true;
}
echo "<li><a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>$name</a>\n";
echo "<li>" . ($result
? "<a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>$name</a>\n"
: "$name: <span class='error'>" . error() . "</span>\n");
}
}
}
Expand Down

0 comments on commit 312075d

Please sign in to comment.