Add error handling to abook db lookups
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 2 Jul 2008 03:30:03 +0000 (03:30 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 2 Jul 2008 03:30:03 +0000 (03:30 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13204 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/abook_database.php

index ceeba5e..1e69af3 100644 (file)
@@ -316,8 +316,13 @@ class abook_database extends addressbook_backend {
             return false;
         }
 
+        $db_field = $this->get_field_name($field);
+        if ($db_field == 'ERROR') {
+            return $this->set_error(sprintf(_("Unknown field name: %s"), $field));
+        }
+
         $query = sprintf("SELECT * FROM %s WHERE owner = '%s' AND LOWER(%s) = '%s'",
-                         $this->table, $this->owner, $this->get_field_name($field)
+                         $this->table, $this->owner, $db_field
                          $this->dbh->quoteString($value));
 
         $res = $this->dbh->query($query);