From 29e2dbfe923de41569f0719903956b1819e25ac1 Mon Sep 17 00:00:00 2001 From: Florian Schlichting Date: Sat, 8 Apr 2017 21:42:59 +0200 Subject: [PATCH] cardquery: a prop-filter without an actual filter rule means we simply need to ensure the property exists This guards against a crash when calling ->GetNSTag() on a non-object. This may need to be refined in case we could be dealing with something that's not a prop-filter. --- inc/caldav-REPORT-cardquery.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/inc/caldav-REPORT-cardquery.php b/inc/caldav-REPORT-cardquery.php index 9b89db6f..9c6c2b1e 100644 --- a/inc/caldav-REPORT-cardquery.php +++ b/inc/caldav-REPORT-cardquery.php @@ -109,13 +109,20 @@ function SqlFilterCardDAV( $filter, $components, $property = null, $parameter = $sql = ""; $params = array(); + // a prop-filter without an actual filter rule means we simply need to ensure the property exists + if ( !is_object($filter) ) { + if ( empty($property) ) return false; + $sql .= $property . ' IS NOT NULL'; + return array( 'sql' => $sql, 'params' => $params ); + } + $tag = $filter->GetNSTag(); dbg_error_log("cardquery", "Processing $tag into SQL - %d, '%s', %d\n", count($components), $property, isset($parameter) ); $not_defined = ""; switch( $tag ) { case 'urn:ietf:params:xml:ns:carddav:is-not-defined': - $sql .= $property . 'IS NULL'; + $sql .= $property . ' IS NULL'; break; case 'urn:ietf:params:xml:ns:carddav:text-match':