Skip to content

Commit

Permalink
fix for escaping categories
Browse files Browse the repository at this point in the history
  • Loading branch information
libasys committed Sep 13, 2015
1 parent 09b1891 commit 3d2ceb7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
4 changes: 3 additions & 1 deletion appinfo/app.php
Expand Up @@ -33,7 +33,7 @@
'order' => 1,
'name' => $c->query('L10N')->t('Calendar+'),
'href' => $c->query('URLGenerator')->linkToRoute($c->getAppName().'.page.index'),
'icon' => $c->query('URLGenerator')->imagePath($c->getAppName(), 'calendar.svg'),
'icon' => $c->query('URLGenerator')->imagePath($c->getAppName(), 'calendarplus.svg'),
];
};
$c->getServer()->getNavigationManager()->add($navigationEntry);
Expand All @@ -50,6 +50,8 @@

\OCA\CalendarPlus\Hooks::register();

\Sabre\VObject\Component\VCalendar::$propertyMap['CATEGORIES'] = '\OCA\CalendarPlus\VObject\StringPropertyCategories';

\OCP\Util::addScript($appName,'alarm');

if (\OCP\User::isLoggedIn() && !\OCP\App::isEnabled('calendar')) {
Expand Down
54 changes: 54 additions & 0 deletions lib/vobject/stringpropertycategories.php
@@ -0,0 +1,54 @@
<?php

namespace OCA\CalendarPlus\VObject;

use \Sabre\VObject;

class StringPropertyCategories extends \Sabre\VObject\Property\Text {


/**
* Turns the object back into a serialized blob.
*
* @return string
*/
public function serialize() {

$str = $this->name;
if ($this->group) {
$str = $this->group . '.' . $this->name;
}


$src = array(
';',
);
$out = array(
',',
);

if(is_array($this->value)){
$this->value = implode(',',$this->value);
}

$value = strtr($this->value, array('\,' => ',', '\;' => ';'));
$str.=':' . str_replace($src, $out, $value);

$out = '';
while(strlen($str) > 0) {
if (strlen($str) > 75) {
$out .= mb_strcut($str, 0, 75, 'utf-8') . "\r\n";
$str = ' ' . mb_strcut($str, 75, strlen($str), 'utf-8');
} else {
$out .= $str . "\r\n";
$str = '';
break;
}
}

return $out;

}


}
2 changes: 1 addition & 1 deletion service/objectparser.php
Expand Up @@ -660,7 +660,7 @@ public function updateVCalendarFromRequest($request, $vcalendar) {
$vevent->setString('CLASS', $accessclass);
$vevent->setString('LOCATION', $location);
$vevent->setString('DESCRIPTION', $description);
$vevent->setString('CATEGORIES', $categories);
$vevent->CATEGORIES = $categories;
$vevent->setString('URL', $link);


Expand Down

0 comments on commit 3d2ceb7

Please sign in to comment.