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 ceeba5e9e4b14c86760e7f5bf5f89f53e041a1a5..1e69af3a0c3ddcd2bd47289826b6c420073c9a7b 100644 (file)
@@ -316,8 +316,13 @@ class abook_database extends addressbook_backend {
             return false;
         }
 
             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'",
         $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);
                          $this->dbh->quoteString($value));
 
         $res = $this->dbh->query($query);