Skip to content

Commit f36f420

Browse files
committed
1 parent 5fe10eb commit f36f420

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

js/timer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
id: 'confirm-button',
103103
text: "Confirm",
104104
click: function() {
105-
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/add-work-interval/'+$('#name-manual-entry').val());
105+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/add-work-interval/'+encodeURIComponent(encodeURIComponent($('#name-manual-entry').val()))); // encode twice so we can have slashes
106106

107107
var jqxhr = $.post( baseUrl,{start:picker.data('daterangepicker').startDate.format('DD/MM/YY HH:mm'), end:picker.data('daterangepicker').endDate.format('DD/MM/YY HH:mm'), tzoffset: new Date().getTimezoneOffset(), details:$('#details-manual-entry').val()} ,function() {
108108
getWorkItems();
@@ -508,7 +508,7 @@
508508
if (workName == ''){
509509
workName = 'no description';
510510
}
511-
var jqxhr = $.post( "ajax/start-timer/"+workName, { projectId: projectId, tags: tags}, function() {
511+
var jqxhr = $.post( "ajax/start-timer/"+encodeURIComponent(encodeURIComponent(workName)), { projectId: projectId, tags: tags}, function() {
512512
localStorage.setItem('isTimerStarted', true);
513513
$('#start-tracking > span').addClass("stop-button").removeClass("play-button");
514514
getWorkItems();
@@ -530,7 +530,7 @@
530530
if (workName == ''){
531531
workName = 'no description';
532532
}
533-
var jqxhr = $.post( "ajax/stop-timer/"+workName, function() {
533+
var jqxhr = $.post( "ajax/stop-timer/"+encodeURIComponent(encodeURIComponent(workName)), function() { // encode twice so we can pass / character
534534
localStorage.setItem('isTimerStarted', false);
535535
$('#start-tracking > span').addClass("play-button").removeClass("stop-button");
536536
getWorkItems();

lib/Controller/AjaxController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function index() {
147147
public function startTimer($name) {
148148
//$this->endTimer();
149149
$projectId = null;
150+
$name = urldecode($name);
150151
if (isset($this->request->projectId) && (!empty($this->request->projectId))){
151152
$projectId = $this->request->projectId;
152153
}
@@ -219,6 +220,7 @@ public function startTimer($name) {
219220
*/
220221

221222
public function stopTimer($name) {
223+
$name = urldecode($name);
222224
if (strlen($name) > 255){
223225
return new JSONResponse(["Error" => "Name too long"]);
224226
}
@@ -350,7 +352,7 @@ public function addWorkInterval() {
350352
$wi->setRunning(0);
351353

352354
if (isset($this->request->name)) {
353-
$wi->setName($this->request->name);
355+
$wi->setName(urldecode($this->request->name));
354356
}
355357
if (isset($this->request->details)) {
356358
if (strlen($this->request->details) > 1024){

0 commit comments

Comments
 (0)