Skip to content
Permalink
Browse files

Fixed broken link rendering for external links at start of line

External links at the start of line like 'www.example.com' were
not rendered as links any more. The issue was introduced with PR #1988.
Fixes #2399.
  • Loading branch information...
LarsGit223 committed Jun 21, 2018
1 parent e954c88 commit 605005e8c222833b31d91aada31f0ebda49bf6d5
Showing with 16 additions and 2 deletions.
  1. +14 −0 _test/tests/inc/parser/parser_links.test.php
  2. +2 −2 inc/parser/parser.php
@@ -144,6 +144,20 @@ function testExternalWWWLink() {
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalWWWLinkStartOfLine() {
// Regression test for issue #2399
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('externallink',array('http://www.google.com', 'www.google.com')),
array('cdata',array(' Bar')),
array('p_close',array()),
array('document_end',array()),
);
$instructions = p_get_instructions("www.google.com Bar");
$this->assertEquals(array_map('stripByteIndex',$instructions),$calls);
}
function testExternalWWWLinkInPath() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
// See issue #936. Should NOT generate a link!
@@ -955,8 +955,8 @@ function preConnect() {
$this->patterns[] = '\b(?i)'.$scheme.'(?-i)://['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
}
$this->patterns[] = '(?<=\s)(?i)www?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '(?<=\s)(?i)ftp?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '(?<!/)\b(?i)www?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '(?<!/)\b(?i)ftp?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
}
function connectTo($mode) {

0 comments on commit 605005e

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.