[aur-dev] [PATCH 1/2] aurjson.class.php: Fix "Undefined index" notices

Lukas Fleischer lfleischer at archlinux.org
Thu Sep 24 17:30:58 UTC 2015


Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
 web/lib/aurjson.class.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index e646c63..dd3c0f0 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -110,8 +110,8 @@ class AurJSON {
 			return;
 		}
 
-		$callback = $http_data['callback'];
-		if (isset($callback)) {
+		if (array_key_exists('callback', $http_data)) {
+			$callback = $http_data['callback'];
 			if (!preg_match('/^[a-zA-Z0-9().]{1,128}$/D', $callback)) {
 				return $this->json_error('Invalid callback name.');
 			}
@@ -281,11 +281,15 @@ class AurJSON {
 				 * proper data types in the JSON response.
 				 */
 				foreach (self::$numeric_fields as $field) {
-					$row[$field] = intval($row[$field]);
+					if (array_key_exists($field, $row)) {
+						$row[$field] = intval($row[$field]);
+					}
 				}
 
 				foreach (self::$decimal_fields as $field) {
-					$row[$field] = floatval($row[$field]);
+					if (array_key_exists($field, $row)) {
+						$row[$field] = floatval($row[$field]);
+					}
 				}
 
 				if ($this->version >= 2 && ($type == 'info' || $type == 'multiinfo')) {
-- 
2.5.3


More information about the aur-dev mailing list