Skip to content

Commit

Permalink
ブログカテゴリ一覧等のウィジェットのURLが有効でないものになってしまう問題を改善 fix baserproject#2011
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Apr 3, 2023
1 parent f6d3280 commit affa953
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/baser-core/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);

// index.php をつけたURLの場合、base の値が正常でなくなり、
// 内部リンクが影響を受けておかしくなってしまうため強制的に Not Found とする
if(preg_match('/\/index\.php\//', $this->getRequest()->getAttribute('base'))) {
$this->notFound();
}

if (!$this->getRequest()->is('requestview')) return;

$response = $this->redirectIfIsRequireMaintenance();
Expand Down
4 changes: 4 additions & 0 deletions plugins/bc-blog/src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public function archives(
break;

case 'author':
if(count($pass) > 2) $this->notFound();
$author = isset($pass[1])? $pass[1] : '';
$this->set($service->getViewVarsForArchivesByAuthor(
$this->paginate($blogPostsService->getIndexByAuthor($author, [
Expand All @@ -251,6 +252,7 @@ public function archives(
break;

case 'tag':
if(count($pass) > 2) $this->notFound();
$tag = isset($pass[1])? $pass[1] : '';
$this->set($service->getViewVarsForArchivesByTag(
$this->paginate($blogPostsService->getIndexByTag($tag, [
Expand All @@ -264,6 +266,7 @@ public function archives(
break;

case 'date':
if(count($pass) > 4) $this->notFound();
$year = $month = $day = '';
if (isset($pass[1]) && preg_match('/^\d{4}$/', $pass[1])) {
$year = $pass[1];
Expand All @@ -288,6 +291,7 @@ public function archives(
break;

default:
if(count($pass) > 1) $this->notFound();
$this->set($service->getViewVarsForSingle(
$this->getRequest(),
$blogContent,
Expand Down

0 comments on commit affa953

Please sign in to comment.