basercms icon indicating copy to clipboard operation
basercms copied to clipboard

SSL時にURLがフルパスになる条件が逆になっている

Open MKGaru opened this issue 1 year ago • 0 comments

概要

baserCMS version : 5.1.3

ソースコード BcBaserHelper->getLinkでは、

 現在SSLの場合、特定の条件でフルパスとする
 - //(スラッシュスラッシュ)から始まるURL
 - http / https 以外のプロトコル
 - ハッシュタグから始まるURL

等の条件でフルパスになる挙動を想定したコメントに見えるのですが、挙動としては一部反転していそうです。

備考

検証コード:

function test($srcUrl) {
$full = false;
$installed = true;
$ssl = true;
if ($installed
    && ($ssl)
    && !(preg_match('/^(javascript|https?|ftp|tel|mailto):/', $srcUrl))
    && !(strpos($srcUrl, '//') === 0)
    && !preg_match('/^#/', $srcUrl)
) {
    $full = true;
}

echo ($full ? '(true)  ' : '(false) ') . $srcUrl."\n";
}

test('./test/ab');
test('/test/ab');
test('//test/ab');
test('data-app://test/ab');
test('https://example.com');
test('javascript://void 0');
test('#/test/ab');
(true)  ./test/ab
(true)  /test/ab
(false) //test/ab
(true)  data-app://test/ab
(false) https://example.com
(false) javascript://void 0
(false) #/test/ab

MKGaru avatar Nov 03 '24 09:11 MKGaru