From ec59bc07aa271fd6d32f1fdfa7ce9929ed5702be Mon Sep 17 00:00:00 2001 From: Jean-Pierre Morfin Date: Fri, 31 Mar 2023 14:29:17 +0200 Subject: [PATCH] Sur la branche master: v2.23 correct filed with carriage return --- class/CardDAVDolibarr.php | 18 +++++++++++++++++- core/modules/modCDav.class.php | 2 +- lib/cdav.lib.php | 12 ++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/class/CardDAVDolibarr.php b/class/CardDAVDolibarr.php index 898da0c..991517d 100644 --- a/class/CardDAVDolibarr.php +++ b/class/CardDAVDolibarr.php @@ -271,6 +271,14 @@ protected function _contactToVCard($obj) $address[]=''; $address[]=''; + // remove carriage return in data + $objvars = get_object_vars($obj); + foreach ($objvars as $key => $value) + { + if(is_string($value)) + $obj->$key = strtr(trim($value), array("\n"=>"\\n", "\r"=>"")); + } + $carddata ="BEGIN:VCARD\n"; $carddata.="VERSION:3.0\n"; $carddata.="PRODID:-//Dolibarr CDav//FR\n"; @@ -398,7 +406,15 @@ protected function _thirdpartyToVCard($obj) } $address[]=''; $address[]=''; - + + // remove carriage return in data + $objvars = get_object_vars($obj); + foreach ($objvars as $key => $value) + { + if(is_string($value)) + $obj->$key = strtr(trim($value), array("\n"=>"\\n", "\r"=>"")); + } + $carddata ="BEGIN:VCARD\n"; $carddata.="VERSION:3.0\n"; $carddata.="PRODID:-//Dolibarr CDav//FR\n"; diff --git a/core/modules/modCDav.class.php b/core/modules/modCDav.class.php index 2e6fdae..5310c38 100644 --- a/core/modules/modCDav.class.php +++ b/core/modules/modCDav.class.php @@ -58,7 +58,7 @@ function __construct($db) // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Allows caldav and carddav clients to sync with Dolibarr."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = '2.22'; + $this->version = '2.23'; // Key used in llx_const table to save module status enabled/disabled (where CDAV is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/lib/cdav.lib.php b/lib/cdav.lib.php index 7f6f15e..0099ad7 100644 --- a/lib/cdav.lib.php +++ b/lib/cdav.lib.php @@ -231,9 +231,9 @@ public function toVCalendar($calid, $obj, $bHeader) $caldata.="UID:".$obj->id.'-ev-'./*$calid.'-cal-'.*/ CDAV_URI_KEY."\n"; else $caldata.="UID:".$obj->sourceuid."\n"; - $caldata.="SUMMARY:".$obj->label."\n"; + $caldata.="SUMMARY:".strtr(trim($obj->label), array("\n"=>"\\n", "\r"=>""))."\n"; $caldata.="URL:".dol_buildpath("/comm/action/card.php?id=".$obj->id, 2)."\n"; - $caldata.="LOCATION:".$location."\n"; + $caldata.="LOCATION:".strtr(trim($location), array("\n"=>"\\n", "\r"=>""))."\n"; $caldata.="PRIORITY:".$obj->priority."\n"; if($obj->fulldayevent) { @@ -285,9 +285,9 @@ public function toVCalendar($calid, $obj, $bHeader) if(!empty($obj->proj_desc)) $caldata.="πŸ’Όβš οΈ ".strtr(trim(strip_tags($obj->proj_desc)), array("\n"=>"\\nπŸ’Όβš οΈ ", "\r"=>""))."\\n"; if(!empty($obj->soc_town)) - $caldata.="πŸ’ΌπŸ ".$obj->soc_town."\\n"; + $caldata.="πŸ’ΌπŸ ".strtr(trim($obj->soc_town), array("\n"=>"\\n", "\r"=>""))."\\n"; if(!empty($obj->soc_nom)) - $caldata.="πŸ’ΌπŸ’ ".$obj->soc_nom."\\n"; + $caldata.="πŸ’ΌπŸ’ ".strtr(trim($obj->soc_nom), array("\n"=>"\\n", "\r"=>""))."\\n"; if(!empty($obj->soc_phone)) $caldata.="πŸ’Όβ˜ŽοΈ ".$obj->soc_phone."\\n"; if(!empty($obj->firstname) || !empty($obj->lastname)) @@ -336,9 +336,9 @@ public function toVCalendar($calid, $obj, $bHeader) $caldata.="LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n"; $caldata.="DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n"; $caldata.="UID:".$obj->id.'-'.$obj->elem_source.'-'./*$calid.'-cal-'.*/ CDAV_URI_KEY."\n"; - $caldata.="SUMMARY:[".$obj->proj_title."]".$obj->label."\n"; + $caldata.="SUMMARY:[".strtr(trim($obj->proj_title), array("\n"=>"\\n", "\r"=>""))."]".strtr(trim($obj->label), array("\n"=>"\\n", "\r"=>""))."\n"; $caldata.="URL:".dol_buildpath("/projet/tasks/task.php?id=".$obj->id."&withproject=".$obj->fk_projet,2)."\n"; - $caldata.="LOCATION:".$location."\n"; + $caldata.="LOCATION:".strtr(trim($location), array("\n"=>"\\n", "\r"=>""))."\n"; $caldata.="PRIORITY:".$obj->priority."\n"; $caldata.="DTSTART;TZID=".$timezone.":".strtr($obj->dateo,array(" "=>"T", ":"=>"", "-"=>""))."\n";