From 76de92477f42a9c52ce5f55fc8e91e19d4b3513d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 9 Jun 2012 14:37:52 +0200 Subject: fix infinite redirect during setup for windows hosts --- lib/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index d86a39966ee..f85710ddfcf 100644 --- a/lib/base.php +++ b/lib/base.php @@ -124,7 +124,7 @@ class OC{ // calculate the documentroot $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13)); - OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT)); + OC::$SUBURI= str_replace("\\","/",substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT))); $scriptName=$_SERVER["SCRIPT_NAME"]; if(substr($scriptName,-1)=='/'){ $scriptName.='index.php'; -- cgit v1.2.3 From 014895aeab547ce30b91c291b3d517d2dcc1c047 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Jun 2012 14:32:02 +0200 Subject: Check for missing path_info, also use OC_Response for 404 error --- remote.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/remote.php b/remote.php index 7131dfc9407..b1be50f36a7 100644 --- a/remote.php +++ b/remote.php @@ -7,13 +7,17 @@ if (array_key_exists('PATH_INFO', $_SERVER)){ }else{ $path_info = substr($_SERVER['PHP_SELF'], strpos($_SERVER['PHP_SELF'], basename(__FILE__)) + strlen(basename(__FILE__))); } +if ($path_info === false) { + OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); + exit; +} if (!$pos = strpos($path_info, '/', 1)) { $pos = strlen($path_info); } $service=substr($path_info, 1, $pos-1); $file = OC_AppConfig::getValue('core', 'remote_' . $service); if(is_null($file)){ - header('HTTP/1.0 404 Not Found'); + OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); exit; } @@ -22,4 +26,4 @@ $app=$parts[2]; OC_App::loadApp($app); $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; -require_once(OC::$APPSROOT . $file); \ No newline at end of file +require_once(OC::$APPSROOT . $file); -- cgit v1.2.3 From 4aee5a7ce43cb6d4c64838aa20d5f09adeba57ca Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Jun 2012 14:32:51 +0200 Subject: Tasks: Use POST for ajax calls that change data --- apps/tasks/ajax/addtask.php | 2 +- apps/tasks/ajax/delete.php | 2 +- apps/tasks/js/tasks.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php index d6e313bd089..9f35e7f21ec 100644 --- a/apps/tasks/ajax/addtask.php +++ b/apps/tasks/ajax/addtask.php @@ -8,7 +8,7 @@ $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true); $first_calendar = reset($calendars); $cid = $first_calendar['id']; -$input = $_GET['text']; +$input = $_POST['text']; $request = array(); $request['summary'] = $input; $request["categories"] = null; diff --git a/apps/tasks/ajax/delete.php b/apps/tasks/ajax/delete.php index 6d2868748d1..e29add9b556 100644 --- a/apps/tasks/ajax/delete.php +++ b/apps/tasks/ajax/delete.php @@ -24,7 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('tasks'); -$id = $_GET['id']; +$id = $_POST['id']; $task = OC_Calendar_App::getEventObject( $id ); OC_Calendar_Object::delete($id); diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index 60d2a523be1..d1e3a9969b4 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -440,7 +440,7 @@ $(document).ready(function(){ $('#tasks_delete').live('click',function(){ var id = $('#task_details').data('id'); - $.getJSON('ajax/delete.php',{'id':id},function(jsondata){ + $.post('ajax/delete.php',{'id':id},function(jsondata){ if(jsondata.status == 'success'){ $('#tasks [data-id="'+jsondata.data.id+'"]').remove(); $('#task_details').data('id',''); @@ -455,7 +455,7 @@ $(document).ready(function(){ $('#tasks_addtask').click(function(){ var input = $('#tasks_newtask').val(); - $.getJSON(OC.filePath('tasks', 'ajax', 'addtask.php'),{text:input},function(jsondata){ + $.post(OC.filePath('tasks', 'ajax', 'addtask.php'),{text:input},function(jsondata){ if(jsondata.status == 'success'){ $('#tasks_list').append(OC.Tasks.create_task_div(jsondata.task)); } -- cgit v1.2.3 From 28ab92ee76c3528637f543c45644e26859fcdb60 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 9 Jun 2012 14:40:15 +0200 Subject: make use of post instead of get --- apps/calendar/ajax/calendar/edit.form.php | 2 +- apps/calendar/ajax/changeview.php | 2 +- apps/calendar/ajax/event/edit.form.php | 2 +- apps/calendar/ajax/import/import.php | 4 ++-- apps/calendar/ajax/settings/guesstimezone.php | 4 ++-- apps/calendar/ajax/share/activation.php | 4 ++-- apps/calendar/ajax/share/changepermission.php | 10 +++++----- apps/calendar/ajax/share/dropdown.php | 2 +- apps/calendar/ajax/share/share.php | 8 ++++---- apps/calendar/ajax/share/unshare.php | 8 ++++---- apps/calendar/js/calendar.js | 16 ++++++++-------- apps/calendar/js/geo.js | 2 +- apps/calendar/js/loader.js | 2 +- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/apps/calendar/ajax/calendar/edit.form.php b/apps/calendar/ajax/calendar/edit.form.php index 77366809311..036ed12bb74 100644 --- a/apps/calendar/ajax/calendar/edit.form.php +++ b/apps/calendar/ajax/calendar/edit.form.php @@ -11,7 +11,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); -$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); +$calendar = OC_Calendar_App::getCalendar($_POST['calendarid']); $tmpl = new OCP\Template("calendar", "part.editcalendar"); $tmpl->assign('new', false); $tmpl->assign('calendarcolor_options', $calendarcolor_options); diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index 2c2d09ccb12..0099fd5ec21 100644 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -7,7 +7,7 @@ */ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); -$view = $_GET['v']; +$view = $_POST['v']; switch($view){ case 'agendaWeek': case 'month'; diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index f2ea84dd205..dbb78edb798 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -13,7 +13,7 @@ if(!OCP\User::isLoggedIn()) { } OCP\JSON::checkAppEnabled('calendar'); -$id = $_GET['id']; +$id = $_POST['id']; $data = OC_Calendar_App::getEventObject($id, true, true); if(!$data){ diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index a3eaed844a1..6fdad12c085 100644 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -16,9 +16,9 @@ $nl="\r\n"; $comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); global $progresskey; -$progresskey = 'calendar.import-' . $_GET['progresskey']; +$progresskey = 'calendar.import-' . $_POST['progresskey']; -if (isset($_GET['progress']) && $_GET['progress']) { +if (isset($_POST['progress']) && $_POST['progress']) { echo OC_Cache::get($progresskey); die; } diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php index 13092777b78..f36f3bf061f 100644 --- a/apps/calendar/ajax/settings/guesstimezone.php +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -12,8 +12,8 @@ OCP\JSON::checkAppEnabled('calendar'); $l = OC_L10N::get('calendar'); -$lat = $_GET['lat']; -$lng = $_GET['long']; +$lat = $_POST['lat']; +$lng = $_POST['lng']; $timezone = OC_Geo::timezone($lat, $lng); diff --git a/apps/calendar/ajax/share/activation.php b/apps/calendar/ajax/share/activation.php index 7d6b8fcb16e..bce8693577b 100644 --- a/apps/calendar/ajax/share/activation.php +++ b/apps/calendar/ajax/share/activation.php @@ -5,7 +5,7 @@ * later. * See the COPYING-README file. */ -$id = strip_tags($_GET['id']); -$activation = strip_tags($_GET['activation']); +$id = strip_tags($_POST['id']); +$activation = strip_tags($_POST['activation']); OC_Calendar_Share::set_active(OCP\USER::getUser(), $id, $activation); OCP\JSON::success(); diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php index 2737420c94e..e807c164a23 100644 --- a/apps/calendar/ajax/share/changepermission.php +++ b/apps/calendar/ajax/share/changepermission.php @@ -6,9 +6,9 @@ * See the COPYING-README file. */ -$id = strip_tags($_GET['id']); -$idtype = strip_tags($_GET['idtype']); -$permission = (int) strip_tags($_GET['permission']); +$id = strip_tags($_POST['id']); +$idtype = strip_tags($_POST['idtype']); +$permission = (int) strip_tags($_POST['permission']); switch($idtype){ case 'calendar': case 'event': @@ -25,8 +25,8 @@ if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){ OCP\JSON::error(array('message'=>'permission denied')); exit; } -$sharewith = $_GET['sharewith']; -$sharetype = strip_tags($_GET['sharetype']); +$sharewith = $_POST['sharewith']; +$sharetype = strip_tags($_POST['sharetype']); switch($sharetype){ case 'user': case 'group': diff --git a/apps/calendar/ajax/share/dropdown.php b/apps/calendar/ajax/share/dropdown.php index a3b0faca4bf..86cf4ac090e 100644 --- a/apps/calendar/ajax/share/dropdown.php +++ b/apps/calendar/ajax/share/dropdown.php @@ -7,7 +7,7 @@ */ $user = OCP\USER::getUser(); -$calid = $_GET['calid']; +$calid = $_POST['calid']; $calendar = OC_Calendar_Calendar::find($calid); if($calendar['userid'] != $user){ OCP\JSON::error(); diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php index 629a7b6b79f..838db619f62 100644 --- a/apps/calendar/ajax/share/share.php +++ b/apps/calendar/ajax/share/share.php @@ -6,8 +6,8 @@ * See the COPYING-README file. */ -$id = strip_tags($_GET['id']); -$idtype = strip_tags($_GET['idtype']); +$id = strip_tags($_POST['id']); +$idtype = strip_tags($_POST['idtype']); switch($idtype){ case 'calendar': case 'event': @@ -24,8 +24,8 @@ if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){ OCP\JSON::error(array('message'=>'permission denied')); exit; } -$sharewith = $_GET['sharewith']; -$sharetype = strip_tags($_GET['sharetype']); +$sharewith = $_POST['sharewith']; +$sharetype = strip_tags($_POST['sharetype']); switch($sharetype){ case 'user': case 'group': diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php index fe7c98452d7..1ce04677fb1 100644 --- a/apps/calendar/ajax/share/unshare.php +++ b/apps/calendar/ajax/share/unshare.php @@ -6,8 +6,8 @@ * See the COPYING-README file. */ -$id = strip_tags($_GET['id']); -$idtype = strip_tags($_GET['idtype']); +$id = strip_tags($_POST['id']); +$idtype = strip_tags($_POST['idtype']); switch($idtype){ case 'calendar': case 'event': @@ -24,8 +24,8 @@ if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){ OCP\JSON::error(array('message'=>'permission denied')); exit; } -$sharewith = $_GET['sharewith']; -$sharetype = strip_tags($_GET['sharetype']); +$sharewith = $_POST['sharewith']; +$sharetype = strip_tags($_POST['sharetype']); switch($sharetype){ case 'user': case 'group': diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index b5411d3fd95..f869fcf2ad2 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -77,7 +77,7 @@ Calendar={ $('#event').dialog('destroy').remove(); }else{ Calendar.UI.loading(true); - $('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.php') + '?id=' + id, Calendar.UI.startEventDialog); + $('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.php'), {id: id}, Calendar.UI.startEventDialog); } }, submitDeleteEventForm:function(url){ @@ -413,7 +413,7 @@ Calendar={ }, edit:function(object, calendarid){ var tr = $(document.createElement('tr')) - .load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php') + "?calendarid="+calendarid, + .load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php'), {calendarid: calendarid}, function(){Calendar.UI.Calendar.colorPicker(this)}); $(object).closest('tr').after(tr).hide(); }, @@ -502,14 +502,14 @@ Calendar={ currentid: 'false', idtype: '', activation:function(object,owner,id){ - $.getJSON(OC.filePath('calendar', 'ajax/share', 'activation.php'),{id:id, idtype:'calendar', activation:object.checked?1:0}); + $.post(OC.filePath('calendar', 'ajax/share', 'activation.php'),{id:id, idtype:'calendar', activation:object.checked?1:0}); $('#calendar_holder').fullCalendar('refetchEvents'); }, dropdown:function(userid, calid){ $('.calendar_share_dropdown').remove(); var element = document.getElementById(userid+'_'+calid); $('
').appendTo(element); - $.get(OC.filePath('calendar', 'ajax/share', 'dropdown.php') + '?calid=' + calid, function(data){ + $.post(OC.filePath('calendar', 'ajax/share', 'dropdown.php'), {calid: calid}, function(data){ $('.calendar_share_dropdown').html(data); $('.calendar_share_dropdown').show('blind'); $('#share_user').chosen(); @@ -519,7 +519,7 @@ Calendar={ Calendar.UI.Share.idtype = 'calendar'; }, share:function(id, idtype, sharewith, sharetype){ - $.getJSON(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ + $.post(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ if(sharetype == 'public'){ $('#public_token').val(parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=calendar&t='+data.message); $('#public_token').css('display', 'block'); @@ -527,7 +527,7 @@ Calendar={ }); }, unshare:function(id, idtype, sharewith, sharetype){ - $.getJSON(OC.filePath('calendar', 'ajax/share', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ + $.post(OC.filePath('calendar', 'ajax/share', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ if(sharetype == 'public'){ $('#public_token').val(''); $('#public_token').css('display', 'none'); @@ -535,7 +535,7 @@ Calendar={ }); }, changepermission:function(id, idtype, sharewith, sharetype, permission){ - $.getJSON(OC.filePath('calendar', 'ajax/share', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); + $.post(OC.filePath('calendar', 'ajax/share', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); }, init:function(){ $('.calendar_share_dropdown').live('mouseleave', function(){ @@ -846,7 +846,7 @@ $(document).ready(function(){ viewDisplay: function(view) { $('#datecontrol_date').html(view.title); if (view.name != defaultView) { - $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name); + $.post(OC.filePath('calendar', 'ajax', 'changeview.php'), {v:view.name}); defaultView = view.name; } Calendar.UI.setViewActive(view.name); diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js index 092d8547469..99290d940e3 100644 --- a/apps/calendar/js/geo.js +++ b/apps/calendar/js/geo.js @@ -6,7 +6,7 @@ */ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { - $.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php') + '?lat=' + position.coords.latitude + '&long=' + position.coords.longitude, + $.post(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php'), {lat: position.coords.latitude, lng: position.coords.longitude}, function(data){ if (data.status == 'success' && typeof(data.message) != 'undefined'){ $('#notification').html(data.message); diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 838521ec7f5..0fc5018e89c 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -63,7 +63,7 @@ Calendar_Import={ }); }, getimportstatus: function(progresskey){ - $.get(OC.filePath('calendar', 'ajax/import', 'import.php') + '?progress=1&progresskey=' + progresskey, function(percent){ + $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {progress:1,progresskey: progresskey}, function(percent){ $('#progressbar').progressbar('option', 'value', parseInt(percent)); if(percent < 100){ window.setTimeout('Calendar_Import.getimportstatus(\'' + progresskey + '\')', 500); -- cgit v1.2.3 From 88341e5797c09d5cdb3c8b7ff713b4a62d51bd60 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 9 Jun 2012 14:53:35 +0200 Subject: Code cleanup. --- apps/contacts/ajax/addproperty.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 2f932d752a7..42b0c782035 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -24,6 +24,12 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); +function bailOut($msg) { + OCP\JSON::error(array('data' => array('message' => $msg))); + OCP\Util::writeLog('contacts','ajax/addproperty.php: '.$msg, OCP\Util::DEBUG); + exit(); +} + $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; $value = isset($_POST['value'])?$_POST['value']:null; @@ -31,11 +37,21 @@ $parameters = isset($_POST['parameters'])?$_POST['parameters']:array(); $vcard = OC_Contacts_App::getContactVCard($id); +if(!$name) { + bailOut(OC_Contacts_App::$l10n->t('element name is not set.')); +} +if(!$id) { + bailOut(OC_Contacts_App::$l10n->t('id is not set.')); +} + +if(!$vcard) { + bailOut(OC_Contacts_App::$l10n->t('Could not parse contact: ').$id); +} + if(!is_array($value)){ $value = trim($value); if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add empty property.')))); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Cannot add empty property.')); } } elseif($name === 'ADR') { // only add if non-empty elements. $empty = true; @@ -46,8 +62,7 @@ if(!is_array($value)){ } } if($empty) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')))); - exit(); + bailOut(OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')); } } @@ -56,9 +71,7 @@ $current = $vcard->select($name); foreach($current as $item) { $tmpvalue = (is_array($value)?implode(';', $value):$value); if($tmpvalue == $item->value) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); - OCP\Util::writeLog('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OCP\Util::DEBUG); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue)); } } @@ -114,9 +127,7 @@ foreach ($parameters as $key=>$element) { $checksum = md5($vcard->children[$line]->serialize()); if(!OC_Contacts_VCard::edit($id,$vcard)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.')))); - OCP\Util::writeLog('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OCP\Util::ERROR); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Error adding contact property: '.$name)); } OCP\JSON::success(array('data' => array( 'checksum' => $checksum ))); -- cgit v1.2.3 From 081e1874cb476a16d7fd2d6ed5dabaeca61fffae Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 9 Jun 2012 15:00:18 +0200 Subject: Contacts: Use POST instead of GET. --- apps/contacts/ajax/deletecard.php | 2 +- apps/contacts/ajax/deleteproperty.php | 4 ++-- apps/contacts/js/contacts.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index 6414fda93cb..e6d0405a240 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -29,7 +29,7 @@ function bailOut($msg) { OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$id = isset($_GET['id'])?$_GET['id']:null; +$id = isset($_POST['id'])?$_POST['id']:null; if(!$id) { bailOut(OC_Contacts_App::$l10n->t('id is not set.')); } diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index b0746d18a79..e6c2bd9f803 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -24,8 +24,8 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$id = $_GET['id']; -$checksum = $_GET['checksum']; +$id = $_POST['id']; +$checksum = $_POST['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 35d4a4a216d..a241856300b 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -368,7 +368,7 @@ Contacts={ $('#contacts_deletecard').tipsy('hide'); OC.dialogs.confirm(t('contacts', 'Are you sure you want to delete this contact?'), t('contacts', 'Warning'), function(answer) { if(answer == true) { - $.getJSON(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){ + $.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){ if(jsondata.status == 'success'){ var newid = ''; var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]'); @@ -707,7 +707,7 @@ Contacts={ Contacts.UI.loading(obj, true); var checksum = Contacts.UI.checksumFor(obj); if(checksum) { - $.getJSON(OC.filePath('contacts', 'ajax', 'deleteproperty.php'),{'id': this.id, 'checksum': checksum },function(jsondata){ + $.post(OC.filePath('contacts', 'ajax', 'deleteproperty.php'),{'id': this.id, 'checksum': checksum },function(jsondata){ if(jsondata.status == 'success'){ if(type == 'list') { Contacts.UI.propertyContainerFor(obj).remove(); -- cgit v1.2.3 From 344299a074e135140262d051531f723be69c786f Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Sat, 9 Jun 2012 15:05:14 +0200 Subject: add two csrf check calls. Review and lot´s of porting needed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/public/util.php | 20 +++++++++++++++++++ lib/util.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/lib/public/util.php b/lib/public/util.php index 9b499574da1..995161e2abe 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -248,6 +248,26 @@ class Util { } + /** + * Register an get/post call. This is important to prevent CSRF attacks + * TODO: write example + */ + public static function callRegister(){ + return(\OC_Util::callRegister()); + } + + + /** + * Check an ajax get/post call if the request token is valid. exit if not. + * Todo: Write howto + */ + public static function callCheck(){ + return(\OC_Util::callCheck()); + } + + + + } ?> diff --git a/lib/util.php b/lib/util.php index 20888fa71f4..ef8ba8efe72 100644 --- a/lib/util.php +++ b/lib/util.php @@ -343,4 +343,60 @@ class OC_Util { } return $id; } + + /** + * Register an get/post call. This is important to prevent CSRF attacks + * Todo: Write howto + */ + public static function callRegister(){ + // generate a random token. + $token=mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000); + + // store the token together with a timestamp in the session. + $_SESSION['requesttoken-'.$token]=time(); + + // return the token + return($token); + } + + + /** + * Check an ajax get/post call if the request token is valid. exit if not. + * Todo: Write howto + */ + public static function callCheck(){ + //mamimum time before token exires + $maxtime=(60*60); // 1 hour + + // searches in the get and post arrays for the token. + if(isset($_GET['requesttoken'])) { + $token=$_GET['requesttoken']; + }elseif(isset($_POST['requesttoken'])){ + $token=$_POST['requesttoken']; + }else{ + //no token found. exiting + exit; + } + + // check if the token is in the user session and if the timestamp is from the last hour. + if(isset($_SESSION['requesttoken-'.$token])) { + $timestamp=$_SESSION['requesttoken-'.$token]; + if($timestamp+$maxtime Date: Sat, 9 Jun 2012 15:07:09 +0200 Subject: fix potential xss in multiselect --- core/js/multiselect.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/js/multiselect.js b/core/js/multiselect.js index 541dddf0f70..5f339006d26 100644 --- a/core/js/multiselect.js +++ b/core/js/multiselect.js @@ -57,8 +57,11 @@ element=$(element); var item=element.val(); var id='ms'+multiSelectId+'-option-'+item; - var input=$(''); - var label=$(''); + var input=$(''); + input.attr('id',id); + var label=$('