From 92b8f3238658782e6eb5a4285185a8fae6665f05 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 2 Feb 2012 15:01:05 +0100 Subject: Calendar: Bugfix: better input validation --- apps/calendar/ajax/createcalendar.php | 2 +- apps/calendar/ajax/events.php | 4 ++-- apps/calendar/ajax/updatecalendar.php | 2 +- apps/calendar/js/calendar.js | 1 + apps/calendar/templates/part.eventform.php | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php index b719b207c74..08bf7b4ee49 100644 --- a/apps/calendar/ajax/createcalendar.php +++ b/apps/calendar/ajax/createcalendar.php @@ -25,7 +25,7 @@ foreach($calendars as $cal){ } $userid = OC_User::getUser(); -$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); +$calendarid = OC_Calendar_Calendar::addCalendar($userid, htmlspecialchars($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, 1); $calendar = OC_Calendar_Calendar::find($calendarid); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 998991c2fb4..75fac6838d7 100644 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -11,8 +11,8 @@ require_once('../../../3rdparty/when/When.php'); function addoutput($event, $vevent, $return_event){ $return_event['id'] = (int)$event['id']; - $return_event['title'] = $event['summary']; - $return_event['description'] = isset($vevent->DESCRIPTION)?$vevent->DESCRIPTION->value:''; + $return_event['title'] = htmlspecialchars($event['summary']); + $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):''; $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified){ $lastmodified = $last_modified->getDateTime()->format('U'); diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php index 269b7b7ca06..90dafd35b68 100644 --- a/apps/calendar/ajax/updatecalendar.php +++ b/apps/calendar/ajax/updatecalendar.php @@ -26,7 +26,7 @@ foreach($calendars as $cal){ $calendarid = $_POST['id']; $calendar = OC_Calendar_App::getCalendar($calendarid);//access check -OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']); +OC_Calendar_Calendar::editCalendar($calendarid, htmlspecialchars($_POST['name']), null, null, null, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index afd1b692dd4..64c029404cb 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -698,6 +698,7 @@ $(document).ready(function(){ eventDrop: Calendar.UI.moveEvent, eventResize: Calendar.UI.resizeEvent, eventRender: function(event, element) { + element.find('span.fc-event-title').html(element.find('span.fc-event-title').text()); element.tipsy({ className: 'tipsy-event', opacity: 0.9, diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 1f2073f4bc7..49214aca77c 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -2,7 +2,7 @@ t("Title");?>: - " value="" maxlength="100" name="title"/> + " value="" maxlength="100" name="title"/> @@ -207,7 +207,7 @@ t("Location");?>: - " value="" maxlength="100" name="location" /> + " value="" maxlength="100" name="location" /> @@ -215,7 +215,7 @@ t("Description");?>: - " name="description"> + " name="description"> -- cgit v1.2.3 From 66b96e4440961483d026473fc6242599b3d51550 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 2 Feb 2012 16:46:38 +0100 Subject: Sanitize in- and output. --- apps/contacts/ajax/addcard.php | 2 +- apps/contacts/ajax/addproperty.php | 2 ++ apps/contacts/ajax/setproperty.php | 6 +++- apps/contacts/templates/part.property.FN.php | 4 +-- apps/contacts/templates/part.property.php | 20 ++++++------- apps/contacts/templates/part.setpropertyform.php | 36 ++++++++++++------------ 6 files changed, 38 insertions(+), 32 deletions(-) diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index 140d6a48095..f15a1685840 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -77,7 +77,7 @@ foreach( $add as $propname){ ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! $value = OC_VObject::escapeSemicolons($value); } - $vcard->addProperty($propname, $value); //, $prop_parameters); + $vcard->addProperty($propname, strip_tags($value)); //, $prop_parameters); $line = count($vcard->children) - 1; foreach ($prop_parameters as $key=>$element) { if(is_array($element) && strtoupper($key) == 'TYPE') { diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index c90af217c87..a00346c7dff 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -67,6 +67,8 @@ foreach($current as $item) { if(is_array($value)) { ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! +} else { + $value = strip_tags($value); } $property = $vcard->addProperty($name, $value); //, $parameters); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php index cf3fe582247..f9e2a8e8647 100644 --- a/apps/contacts/ajax/setproperty.php +++ b/apps/contacts/ajax/setproperty.php @@ -37,9 +37,13 @@ $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $value = $_POST['value']; if(is_array($value)){ ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! + foreach(array_keys($value) as $key) { + OC_Log::write('contacts','ajax/setproperty.php: setting: '.$key.': '.$value[$key], OC_Log::DEBUG); + } + $value = OC_VObject::escapeSemicolons($value); } OC_Log::write('contacts','ajax/setproperty.php: setting: '.$vcard->children[$line]->name.': '.$value, OC_Log::DEBUG); -$vcard->children[$line]->setValue($value); +$vcard->children[$line]->setValue(strip_tags($value)); // Add parameters $postparameters = isset($_POST['parameters'])?$_POST['parameters']:array(); diff --git a/apps/contacts/templates/part.property.FN.php b/apps/contacts/templates/part.property.FN.php index 83cef94e303..c9e21c20e60 100644 --- a/apps/contacts/templates/part.property.FN.php +++ b/apps/contacts/templates/part.property.FN.php @@ -1,9 +1,9 @@ - + diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php index e4010397500..7b23fae45b5 100644 --- a/apps/contacts/templates/part.property.php +++ b/apps/contacts/templates/part.property.php @@ -8,21 +8,21 @@ t('Organization'); ?> - + t('Email'); ?> - + t('Preferred').' ' : '' ?>t('Phone'); ?> - + - + - + - + - + - + - + - + diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php index 49fa9662146..93ade8faaa7 100644 --- a/apps/contacts/templates/part.setpropertyform.php +++ b/apps/contacts/templates/part.setpropertyform.php @@ -5,18 +5,18 @@ t('Given name'); ?> - + t('Family name'); ?> - + t('Additional names'); ?> - - - + + +
- +
t('Organization'); ?>
t('Email'); ?>
t('Preferred').' ' : '' ?>t('Phone'); ?>
- + - + - + - + - + - + - + diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php index 49fa9662146..93ade8faaa7 100644 --- a/apps/contacts/templates/part.setpropertyform.php +++ b/apps/contacts/templates/part.setpropertyform.php @@ -5,18 +5,18 @@
t('Address'); ?>
t('Phone'); ?>
+