Skip to content

Commit

Permalink
指摘事項修正
Browse files Browse the repository at this point in the history
1. 固定ページ、ブログ記事等のスクリプト挿入判別正規表現修正
2. Pluginアップロードの.htaccessファイル拒否追加
  • Loading branch information
gondoh committed Mar 1, 2021
1 parent 7b22ec7 commit 88ccc61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion lib/Baser/Controller/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ public function admin_add()
$plugin = explode(DS, $plugin);
$plugin = $plugin[0];
$srcPluginPath = APP . 'Plugin' . DS . $plugin;
$Folder = new Folder();
$Folder = new Folder($srcPluginPath);
// .htacessファイルが含まれる場合はアップロード不可
$htaccessFiles = $Folder->findRecursive('.*\.htaccess');
if ($htaccessFiles) {
$msg = __d('baser', '.htaccessファイルが含まれるプラグインはアップロードできません。');
$Folder->delete();
$this->BcMessage->setError($msg);
$this->redirect(['action' => 'add']);
return;
}

$Folder->chmod($srcPluginPath, 0777);
$tgtPluginPath = APP . 'Plugin' . DS . Inflector::camelize($plugin);
if ($srcPluginPath != $tgtPluginPath) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Baser/Model/BcAppModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1900,10 +1900,10 @@ public function containsScript($check)
if (preg_match('/(<\?=|<\?php|<script)/i', $value)) {
return false;
}
if (preg_match('/<[^>]+?(' . implode('|', $events) . ')=("|\')[^>]*?>/i', $value)) {
if (preg_match('/<[^>]+?(' . implode('|', $events) . ')\s*=[^<>]*?>/i', $value)) {
return false;
}
if (preg_match('/href=\s*?("|\')[^"\']*?javascript\s*?:/i', $value)) {
if (preg_match('/href\s*=\s*[^>]*?javascript\s*?:/i', $value)) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Baser/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
4.4.4
4.4.5-dev

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
Expand Down

0 comments on commit 88ccc61

Please sign in to comment.