Skip to content

Commit 98ea9ee

Browse files
authored
Update submit.php
1 parent 59fde61 commit 98ea9ee

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

submit.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ function image_drop_upload_ajax() {
426426
function image_delete_ajax() {
427427

428428
$document = $_POST['document'];
429-
$image_filename = $_POST['image_name'];
429+
$image_filename = basename($_POST['image_name']); // added basename()
430430

431431
if (Session::getInstance()->autenticationLevel() != 2) {
432432
// error
@@ -435,6 +435,20 @@ function image_delete_ajax() {
435435
return false;
436436
}
437437

438+
// reject if $document contains .. or any slash/backslash
439+
if (
440+
strpos($document, '..') !== false ||
441+
strpos($document, '/') !== false ||
442+
strpos($document, '\\') !== false
443+
) {
444+
echo json_encode([
445+
"error" => 1,
446+
"code" => "invalid_document"
447+
]);
448+
return false;
449+
}
450+
451+
438452
// initialize document
439453
$DOC = new Document($document);
440454
if(!is_dir($DOC->DIR)){mkdir($DOC->DIR,0755,true);}
@@ -461,7 +475,6 @@ function image_delete_ajax() {
461475
}
462476
}
463477

464-
465478
/**
466479
* Atachment Upload (AJAX)
467480
*/

0 commit comments

Comments
 (0)