Skip to content
Snippets Groups Projects
Commit 79fdbafc authored by LarsDW223's avatar LarsDW223 Committed by Andreas Gohr
Browse files

Adjusted pattern for matching media links to properly handle a single '}' in...

Adjusted pattern for matching media links to properly handle a single '}' in the link text. Fixes #1587.
parent 9ea3d483
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ require_once 'parser.inc.php';
/**
* Tests for the implementation of audio and video files
*
* @group parser_media
* @author Michael Große <grosse@cosmocode.de>
*/
class TestOfDoku_Parser_Media extends TestOfDoku_Parser {
......@@ -131,4 +132,64 @@ class TestOfDoku_Parser_Media extends TestOfDoku_Parser {
$substr_start = strlen($url) - strlen($rest);
$this->assertEquals($rest, substr($url, $substr_start));
}
function testSimpleLinkText() {
$file = 'wiki:dokuwiki-128.png';
$parser_response = p_get_instructions('{{' . $file . '|This is a simple text.}}');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('internalmedia',array($file,'This is a simple text.',null,null,null,'cache','details')),
array('cdata',array(null)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
}
function testLinkTextWithWavedBrackets_1() {
$file = 'wiki:dokuwiki-128.png';
$parser_response = p_get_instructions('{{' . $file . '|We got a { here.}}');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('internalmedia',array($file,'We got a { here.',null,null,null,'cache','details')),
array('cdata',array(null)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
}
function testLinkTextWithWavedBrackets_2() {
$file = 'wiki:dokuwiki-128.png';
$parser_response = p_get_instructions('{{' . $file . '|We got a } here.}}');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('internalmedia',array($file,'We got a } here.',null,null,null,'cache','details')),
array('cdata',array(null)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
}
function testLinkTextWithWavedBrackets_3() {
$file = 'wiki:dokuwiki-128.png';
$parser_response = p_get_instructions('{{' . $file . '|We got a { and a } here.}}');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('internalmedia',array($file,'We got a { and a } here.',null,null,null,'cache','details')),
array('cdata',array(null)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
}
}
......@@ -916,7 +916,7 @@ class Doku_Parser_Mode_media extends Doku_Parser_Mode {
function connectTo($mode) {
// Word boundaries?
$this->Lexer->addSpecialPattern("\{\{[^\}]+\}\}",$mode,'media');
$this->Lexer->addSpecialPattern("\{\{(?:[^\}]|(?:\}[^\}]))+\}\}",$mode,'media');
}
function getSort() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment