mirror of
https://github.com/getgrav/grav.git
synced 2026-07-10 17:23:46 +02:00
Fix for non http/s external links - #738
This commit is contained in:
@@ -3,6 +3,7 @@ namespace Grav\Common\Markdown;
|
||||
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Uri;
|
||||
use Grav\Common\Utils;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,6 @@ trait ParsedownGravTrait
|
||||
protected $pages_dir;
|
||||
protected $special_chars;
|
||||
protected $twig_link_regex = '/\!*\[(?:.*)\]\((\{([\{%#])\s*(.*?)\s*(?:\2|\})\})\)/';
|
||||
protected $special_protocols = ['xmpp', 'mailto', 'tel', 'sms'];
|
||||
|
||||
public $completable_blocks = [];
|
||||
public $continuable_blocks = [];
|
||||
@@ -93,7 +93,7 @@ trait ParsedownGravTrait
|
||||
} else {
|
||||
array_splice($this->InlineTypes[$type], $index, 0, $tag);
|
||||
}
|
||||
|
||||
|
||||
if (strpos($this->inlineMarkerList, $type) === false) {
|
||||
$this->inlineMarkerList .= $type;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ trait ParsedownGravTrait
|
||||
}
|
||||
|
||||
// if special scheme, just return
|
||||
if(isset($url['scheme']) && in_array($url['scheme'], $this->special_protocols)) {
|
||||
if(isset($url['scheme']) && !Utils::startsWith($url['scheme'], 'http')) {
|
||||
return $excerpt;
|
||||
}
|
||||
|
||||
|
||||
@@ -586,6 +586,8 @@ class ParsedownTest extends \Codeception\TestCase\Test
|
||||
$this->parsedown->text('[tel](tel:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
|
||||
$this->parsedown->text('[sms](sms:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
|
||||
$this->parsedown->text('[ts.example.com](rdp://ts.example.com)'));
|
||||
}
|
||||
|
||||
public function testSpecialProtocolsSubDir()
|
||||
@@ -600,6 +602,8 @@ class ParsedownTest extends \Codeception\TestCase\Test
|
||||
$this->parsedown->text('[tel](tel:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
|
||||
$this->parsedown->text('[sms](sms:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
|
||||
$this->parsedown->text('[ts.example.com](rdp://ts.example.com)'));
|
||||
}
|
||||
|
||||
public function testSpecialProtocolsSubDirAbsoluteUrl()
|
||||
@@ -615,6 +619,8 @@ class ParsedownTest extends \Codeception\TestCase\Test
|
||||
$this->parsedown->text('[tel](tel:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
|
||||
$this->parsedown->text('[sms](sms:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
|
||||
$this->parsedown->text('[ts.example.com](rdp://ts.example.com)'));
|
||||
}
|
||||
|
||||
public function testReferenceLinks()
|
||||
|
||||
Reference in New Issue
Block a user