Skip to content

Commit

Permalink
Merge pull request #1628 from Roffun/master
Browse files Browse the repository at this point in the history
Fix #1611: Duplicate path links
  • Loading branch information
Dayver committed Apr 11, 2019
2 parents d01bd71 + a8d4c38 commit a492634
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 0 additions & 3 deletions modules/page/inc/page.list.php
Expand Up @@ -208,9 +208,6 @@
}
// Building the canonical URL
$out['canonical_uri'] = cot_url('page', $pageurl_params);
if ($out['uri'] != $out['canonical_uri']) {
cot_die_message(404, true);
}

$_SESSION['cat'] = $c;

Expand Down
3 changes: 0 additions & 3 deletions modules/page/inc/page.main.php
Expand Up @@ -131,9 +131,6 @@
$pageurl_params['pg'] = $pg;
}
$out['canonical_uri'] = cot_url('page', $pageurl_params);
if ($out['uri'] != $out['canonical_uri']) {
cot_die_message(404, true);
}

$mskin = cot_tplfile(array('page', $cat['tpl']));

Expand Down
8 changes: 8 additions & 0 deletions plugins/urleditor/inc/urleditor.functions.php
Expand Up @@ -140,6 +140,9 @@ function cot_apply_rwr()
{
// Is a category
$_GET['c'] = $path[$last];
if ($rwr !== cot_url($ext, array('c' => $_GET['c']))) {
cot_die_message(404, true);
}
}
else
{
Expand All @@ -159,6 +162,11 @@ function cot_apply_rwr()
$_GET['c'] = $path[$last];
$_GET['al'] = $path[$last];
}
if (!empty($_GET['id'] || $_GET['al']) && $_GET['c']) {
if ($rwr !== cot_url($ext, array('c' => $_GET['c'], !empty($_GET['al']) ? 'al' : 'id' => $path[$last]))) {
cot_die_message(404, true);
}
}
}
}
}
Expand Down

5 comments on commit a492634

@seditio
Copy link
Member

Choose a reason for hiding this comment

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

empty вроде как принимает только один аргумент

@Dayver
Copy link
Member Author

@Dayver Dayver commented on a492634 Apr 12, 2019

Choose a reason for hiding this comment

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

empty вроде как принимает только один аргумент

коротко и ясно :

Версия Описание
5.5.0 empty() теперь поддерживает выражения, а не только переменные.

@seditio
Copy link
Member

Choose a reason for hiding this comment

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

Не вижу совершенно никакой проблемы в том, чтобы empty оформить для совместимости с 5.4. Лично мне все равно, но у массы пользователей случится heart attack при следующем обновлении.
Но есть еще один косяк. Если в урле дублируется непоследний раздел (https://site.com/cat1/cat1/cat2) и отдается 404-я, не подгружаются никакие ресурсы. Т.е. при использовании кастомного error.404.tpl ни массив PHP.cfg, ни PHP.theme, ни лэнг-строки не грузятся.

@seditio
Copy link
Member

Choose a reason for hiding this comment

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

$cfg действительно доступен. $cfg.defaulttheme мало кому нужен, без PHP.L и PHP.R очень больно

@macik
Copy link
Member

@macik macik commented on a492634 Apr 15, 2019

Choose a reason for hiding this comment

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

На уровне идеи:

  • в input вызывается cot_apply_rwr() возвращая false (или код 404) в переменную, в случае если путь не может быть преобразован и должен быть осуществлен возврат с кодом 404.
  • далее на global повесить проверку (от URLeditor) значения сохраненного ранее в переменную, с соответствующим действием на «404».

Please sign in to comment.