Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plugins/baser-core/src/Service/PluginsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,9 @@ public function add(array $postData)
$name = $postData['file']->getClientFileName();
$postData['file']->moveTo(TMP . $name);
$zip = new BcZip();
if (!$zip->extract(TMP . $name, TMP)) {
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file(TMP . $name);
if (!in_array($mimeType, ['application/zip', 'application/x-zip-compressed'], true) || !$zip->extract(TMP . $name, TMP)) {

@teratai3 teratai3 Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すでに extract メソッドは他の箇所でも使われており、このMIME typeのチェックは、ほぼセットで呼び出す必要があると認識しています。
このPRいただいた形だと、今後ほかの箇所で対応する際にも同じ処理をコピーする前提になっており、修正漏れや後から処理を変更するコスト高そうです。
AIで実装する場合も既存コードを参考にすることが多いため、明確な指示をしない限り、同じ形で処理が増えていく可能性はありそうです。

※ updateCoreFiles は、固定のzipなので、必須ではありませんが、ここでもextractは呼び出されています。

Comment thread
ryuring marked this conversation as resolved.
Outdated
throw new BcException(__d('baser_core', 'アップロードしたZIPファイルの展開に失敗しました。'));
}
Comment thread
ryuring marked this conversation as resolved.
Outdated
$srcDirName = $zip->topArchiveName;
Expand Down
Loading