Merge branch '1.7' of github.com:getgrav/grav into 1.7

This commit is contained in:
Andy Miller
2020-07-07 12:28:14 -06:00
2 changed files with 37 additions and 3 deletions

View File

@@ -104,12 +104,16 @@ class Excerpts
// Valid attributes supported.
$valid_attributes = Grav::instance()['config']->get('system.pages.markdown.valid_link_attributes');
$skip = [];
// Unless told to not process, go through actions.
if (array_key_exists('noprocess', $actions)) {
$skip = is_bool($actions['noprocess']) ? $actions : explode(',', $actions['noprocess']);
unset($actions['noprocess']);
} else {
// Loop through actions for the image and call them.
foreach ($actions as $attrib => $value) {
}
// Loop through actions for the image and call them.
foreach ($actions as $attrib => $value) {
if (!in_array($attrib, $skip)) {
$key = $attrib;
if (in_array($attrib, $valid_attributes, true)) {

View File

@@ -87,4 +87,34 @@ class ExcerptsTest extends \Codeception\TestCase\Test
Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)
);
}
public function testNoProcess()
{
$this->assertStringStartsWith(
'<a href="https://play.google.com/store/apps/details?hl=de" id="org.jitsi.meet" target="_blank"',
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank">regular process</a>')
);
$this->assertStringStartsWith(
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank"',
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess">noprocess</a>')
);
$this->assertStringStartsWith(
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de" target="_blank"',
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess=id">noprocess=id</a>')
);
}
public function testTarget()
{
$this->assertStringStartsWith(
'<a href="https://play.google.com/store/apps/details" target="_blank"',
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?target=_blank">only target</a>')
);
$this->assertStringStartsWith(
'<a href="https://meet.weikamp.biz/Support" rel="nofollow" target="_blank"',
Excerpts::processLinkHtml('<a href="https://meet.weikamp.biz/Support?rel=nofollow&target=_blank">target and rel</a>')
);
}
}