diff --git a/lib/yrewrite/forward.php b/lib/yrewrite/forward.php index c601995..c0372ec 100644 --- a/lib/yrewrite/forward.php +++ b/lib/yrewrite/forward.php @@ -2,9 +2,7 @@ /** * YREWRITE Addon. - * - * @author jan.kristinus@yakamara.de - * + * * @package redaxo\yrewrite */ @@ -32,7 +30,7 @@ public static function init(): void public static function getForward($params) { // Url wurde von einer anderen Extension bereits gesetzt - if (isset($params['subject']) && '' != $params['subject']) { + if (isset($params['subject']) && $params['subject'] != '') { return $params['subject']; } @@ -52,8 +50,13 @@ public static function getForward($params) } $pUrl = urldecode($p['url']); - /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/8125 */ - if ($pUrl !== $url && $pUrl . '/' !== $url) { + $wildcardPos = strpos($pUrl, '*'); + if ($wildcardPos !== false) { + $baseUrl = substr($pUrl, 0, $wildcardPos); + if (substr($url, 0, $wildcardPos) !== $baseUrl) { + continue; + } + } elseif ($pUrl !== $url && $pUrl . '/' !== $url) { continue; } @@ -67,20 +70,20 @@ public static function getForward($params) } } - if ('article' == $p['type'] && ($art = rex_article::get($p['article_id'], $p['clang']))) { + if ($p['type'] == 'article' && ($art = rex_article::get($p['article_id'], $p['clang']))) { $forward_url = rex_getUrl($p['article_id'], $p['clang']); - } elseif ('media' == $p['type'] && ($media = rex_media::get($p['media']))) { + } elseif ($p['type'] == 'media' && ($media = rex_media::get($p['media']))) { $forward_url = rex_url::media($p['media']); - } elseif ('extern' == $p['type'] && '' != $p['extern']) { + } elseif ($p['type'] == 'extern' && $p['extern'] != '') { $forward_url = $p['extern']; } - if ('' != $forward_url) { + if ($forward_url != '') { $matchingParams = count($p['params'] ?? []); } } - if ('' != $forward_url) { + if ($forward_url != '') { header('HTTP/1.1 '.self::$movetypes[$p['movetype']]); header('Location: ' . $forward_url); exit; @@ -110,7 +113,7 @@ public static function generatePathFile(): void $row['url'] = mb_strtolower($url[0]); if (isset($url[1])) { - /** @phpstan-ignore-next-line */ + /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/8125 */ parse_str($url[1], $row['params']); } } diff --git a/pages/forward.php b/pages/forward.php index 112f9ef..6e734a8 100644 --- a/pages/forward.php +++ b/pages/forward.php @@ -39,7 +39,7 @@ $yform->setValueField('choice', ['status', $this->i18n('forward_status'), $this->i18n('forward_active').'=1,'.$this->i18n('forward_inactive').'=0']); $yform->setValueField('choice', ['domain_id', $this->i18n('domain'), 'select id,domain as name from '.rex::getTable('yrewrite_domain') . ' ORDER BY name']); $yform->setValueField('text', ['url', $this->i18n('forward_url'), 'notice' => ''.$this->i18n('forward_url_info').'']); - $yform->setValidateField('preg_match', ['url', '@^[%_\.+\-\w]+[/%_\.+\,\-\w]*(?i18n('warning_chars')]); + $yform->setValidateField('preg_match', ['url', '@^[%_\.+\-\w]+[/%_\.+\,\-\w]*(?i18n('warning_chars')]); // $this->i18n('warning_noslash') $yform->setValidateField('size_range', ['url', 1, 255, $this->i18n('warning_nottolong')]); $yform->setValidateField('empty', ['url', $this->i18n('forward_enter_url')]);