From a5aa09d55439944ca952d5949a20e151fba9a8fa Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:32:56 +0300 Subject: [PATCH] fix low register format chekc --- Web/Models/Entities/Document.php | 8 ++++---- Web/static/js/al_docs.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Web/Models/Entities/Document.php b/Web/Models/Entities/Document.php index b5f15cb6..93156720 100644 --- a/Web/Models/Entities/Document.php +++ b/Web/Models/Entities/Document.php @@ -104,7 +104,7 @@ class Document extends Media if(!$file_format) throw new \TypeError("No file format"); - if(!in_array($file_format, OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["allowedFormats"])) + if(!in_array(mb_strtolower($file_format), OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["allowedFormats"])) throw new \TypeError("Forbidden file format"); if($file_size < 1 || $file_size > (OPENVK_ROOT_CONF["openvk"]["preferences"]["docs"]["maxSize"] * 1024 * 1024)) @@ -112,8 +112,8 @@ class Document extends Media $hash = hash_file("whirlpool", $file["tmp_name"]); $this->stateChanges("original_name", ovk_proc_strtr($original_name, 255)); - $this->tmp_format = $file_format; - $this->stateChanges("format", $file_format); + $this->tmp_format = mb_strtolower($file_format); + $this->stateChanges("format", mb_strtolower($file_format)); $this->stateChanges("filesize", $file_size); $this->stateChanges("hash", $hash); $this->stateChanges("access_key", bin2hex(random_bytes(9))); @@ -386,7 +386,7 @@ class Document extends Media static function detectTypeByFormat(string $format) { - switch($format) { + switch(mb_strtolower($format)) { case "txt": case "docx": case "doc": case "odt": case "pptx": case "ppt": case "xlsx": case "xls": case "md": return 1; case "zip": case "rar": case "7z": diff --git a/Web/static/js/al_docs.js b/Web/static/js/al_docs.js index 23ca414d..d9eacd21 100644 --- a/Web/static/js/al_docs.js +++ b/Web/static/js/al_docs.js @@ -27,7 +27,7 @@ function showDocumentUploadDialog(target = null, append_to_url = null, after_upl file = e.target.files[0] const name = file.name const format = name.split(".")[name.split(".").length - 1] - if(window.openvk.docs_allowed.indexOf(format) == -1) { + if(window.openvk.docs_allowed.indexOf(format.toLowerCase()) == -1) { makeError(tr("error_file_invalid_format")) return }