mirror of
https://github.com/moodle/moodle.git
synced 2025-03-03 23:46:09 +01:00
Merge branch 'MDL-41672-text-mail-links' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
b011a17b26
@ -580,9 +580,14 @@ class html2text
|
||||
}
|
||||
|
||||
if (($index = array_search($url, $this->_link_list)) === false) {
|
||||
// Add the link to the list.
|
||||
$this->_link_list[] = $url;
|
||||
$index = count($this->_link_list);
|
||||
}
|
||||
else {
|
||||
// Use the index of the existing link in the list (we enumerate from 1, not from 0).
|
||||
$index++;
|
||||
}
|
||||
|
||||
return $display . ' [' . ($index) . ']';
|
||||
}
|
||||
|
@ -96,6 +96,20 @@ have been fixed <strong><a href="http://third.url/view.php">last week</a></stron
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[2] http://another.url/?f=a&b=2').'$|m', $result));
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[3] http://third.url/view.php').'$|m', $result));
|
||||
$this->assertSame(false, strpos($result, '[4]'));
|
||||
|
||||
// Test multiple occurrences of the same URL.
|
||||
$text = '<p>See <a href="http://moodle.org">moodle.org</a>,
|
||||
<a href="http://www.google.fr">google</a>, <a href="http://www.univ-lemans.fr">univ-lemans</a>
|
||||
and <a href="http://www.google.fr">google</a>.
|
||||
Also try <a href="https://www.google.fr">google via HTTPS</a>.';
|
||||
$result = html_to_text($text, 5000, true);
|
||||
$this->assertSame(0, strpos($result, 'See moodle.org [1], google [2], univ-lemans [3] and google [2]. Also try google via HTTPS [4].'));
|
||||
$this->assertSame(false, strpos($result, '[0]'));
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[1] http://moodle.org').'$|m', $result));
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[2] http://www.google.fr').'$|m', $result));
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[3] http://www.univ-lemans.fr').'$|m', $result));
|
||||
$this->assertSame(1, preg_match('|^'.preg_quote('[4] https://www.google.fr').'$|m', $result));
|
||||
$this->assertSame(false, strpos($result, '[5]'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user