From 4d0974175b02cf383447d2129cf3789e06e81cf8 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 23 Aug 2012 01:18:59 +0200 Subject: [PATCH] Don't add empty property parameters. --- ajax/contact/addproperty.php | 6 +++++- ajax/contact/saveproperty.php | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ajax/contact/addproperty.php b/ajax/contact/addproperty.php index 0447950f..89f7a2bd 100644 --- a/ajax/contact/addproperty.php +++ b/ajax/contact/addproperty.php @@ -141,11 +141,15 @@ foreach ($parameters as $key=>$element) { // And it probably shouldn't be done here anyways :-/ foreach($element as $e) { if($e != '' && !is_null($e)) { - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e); + if(trim($e)) { + $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e); + } } } } else { + if(trim($element)) { $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element); + } } } $checksum = md5($vcard->children[$line]->serialize()); diff --git a/ajax/contact/saveproperty.php b/ajax/contact/saveproperty.php index 9556c4a4..296b9ad3 100644 --- a/ajax/contact/saveproperty.php +++ b/ajax/contact/saveproperty.php @@ -133,17 +133,21 @@ if(!$value) { debug('Adding parameter: '.$key); if(is_array($parameter)) { foreach($parameter as $val) { - debug('Adding parameter: '.$key.'=>'.$val); - $vcard->children[$line]->add(new Sabre_VObject_Parameter( - $key, - strtoupper(strip_tags($val))) - ); + if(trim($val)) { + debug('Adding parameter: '.$key.'=>'.$val); + $vcard->children[$line]->add(new Sabre_VObject_Parameter( + $key, + strtoupper(strip_tags($val))) + ); + } } } else { - $vcard->children[$line]->add(new Sabre_VObject_Parameter( - $key, - strtoupper(strip_tags($parameter))) - ); + if(trim($parameter)) { + $vcard->children[$line]->add(new Sabre_VObject_Parameter( + $key, + strtoupper(strip_tags($parameter))) + ); + } } } }