Permalink
Browse files

Search non-ASCII data only in text columns (bug #3564415)

  • Loading branch information...
1 parent 66d537c commit 312075d01f326c39070d97d576002568bbd7e055 @vrana committed Sep 9, 2012
Showing with 9 additions and 4 deletions.
  1. +5 −2 adminer/include/adminer.inc.php
  2. +4 −2 adminer/include/functions.inc.php
@@ -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");
@@ -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");
}
}
}

0 comments on commit 312075d

Please sign in to comment.