@@ -220,6 +220,26 @@ protected function getHtmlTitle($sUrl)
220220 return isset ($ aTitle ['1 ' ]) ? trim ($ aTitle ['1 ' ]) : '' ;
221221 }
222222
223+ /**
224+ * Checks if file name is allowed.
225+ *
226+ * @param string $FileName
227+ *
228+ * @return bool
229+ */
230+ protected function isFileAllowed ($ FileName )
231+ {
232+ $ forbiddenFileList = [
233+ '.sabredav '
234+ ];
235+
236+ $ FileName = \trim (\MailSo \Base \Utils::ClearFileName ($ FileName ));
237+
238+ $ result = !in_array ($ FileName , $ forbiddenFileList );
239+
240+ return $ result ;
241+ }
242+
223243 /**
224244 * Puts file content to $mResult.
225245 * @ignore
@@ -257,6 +277,10 @@ public function onGetFile($aArgs, &$mResult)
257277 public function onCreateFile ($ aArgs , &$ mResult )
258278 {
259279 if ($ this ->checkStorageType ($ aArgs ['Type ' ])) {
280+ if (!self ::isFileAllowed ($ aArgs ['Name ' ])) {
281+ throw new \Aurora \System \Exceptions \ApiException (\Aurora \System \Notifications::CanNotUploadFileErrorData);
282+ }
283+
260284 $ UserId = $ aArgs ['UserId ' ];
261285 Api::CheckAccess ($ UserId );
262286
@@ -572,6 +596,10 @@ public function onAfterRename(&$aArgs, &$mResult)
572596 $ UserId = $ aArgs ['UserId ' ];
573597 Api::CheckAccess ($ UserId );
574598
599+ if (self ::isFileAllowed ($ aArgs ['Name ' ])) {
600+ throw new \Aurora \System \Exceptions \ApiException (\Aurora \System \Notifications::CanNotUploadFileErrorData);
601+ }
602+
575603 $ sUserPiblicId = Api::getUserPublicIdById ($ UserId );
576604 $ sNewName = \trim (\MailSo \Base \Utils::ClearFileName ($ aArgs ['NewName ' ]));
577605
@@ -635,6 +663,11 @@ public function onAfterMove(&$aArgs, &$mResult)
635663
636664 if (!$ bIntoItself ) {
637665 $ sNewName = isset ($ aItem ['NewName ' ]) ? $ aItem ['NewName ' ] : $ aItem ['Name ' ];
666+
667+ if (self ::IsFileAllowed (basename ($ sNewName ))) {
668+ throw new \Aurora \System \Exceptions \ApiException (\Aurora \System \Notifications::CanNotUploadFileErrorData);
669+ }
670+
638671 $ sNewName = $ this ->getManager ()->getNonExistentFileName (
639672 $ sUserPiblicId ,
640673 $ aArgs ['ToType ' ],
0 commit comments