From 7353c0d287513366d067053c79f8d1b321e399d4 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 May 2015 16:35:14 +0200 Subject: [PATCH] IdoQuery::initializeForPostgres(): cast only valid IP addresses to inet fixes #7165 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 2e6bec024..fda2f188e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -370,7 +370,11 @@ abstract class IdoQuery extends DbQuery if ($count > 0) { $this->columnsWithoutCollation[] = $this->getMappedField($key); } - $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); + $value = preg_replace( + '/inet_aton\(([[:word:].]+)\)/i', + '(CASE WHEN $1 ~ \'(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}\' THEN $1::inet - \'0.0.0.0\' ELSE NULL END)', + $value + ); $value = preg_replace( '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', 'CASE WHEN ($1 < \'1970-01-03 00:00:00+00\'::timestamp with time zone) THEN 0 ELSE UNIX_TIMESTAMP($1) END',