Commit 2d2ff0d1 authored by Dries's avatar Dries
Browse files

- Patch #784790 by sun: URL filter incorrectly repeats URL in link title attribute.

parent 5abc116f
......@@ -1314,7 +1314,7 @@ function _filter_url_parse_full_links($match) {
$match[2] = decode_entities($match[2]);
$caption = check_plain(_filter_url_trim($match[2]));
$match[2] = check_url($match[2]);
return $match[1] . '<a href="' . $match[2] . '" title="' . $match[2] . '">' . $caption . '</a>' . $match[5];
return $match[1] . '<a href="' . $match[2] . '">' . $caption . '</a>' . $match[5];
}
/**
......@@ -1324,7 +1324,7 @@ function _filter_url_parse_partial_links($match) {
$match[2] = decode_entities($match[2]);
$caption = check_plain(_filter_url_trim($match[2]));
$match[2] = check_plain($match[2]);
return $match[1] . '<a href="http://' . $match[2] . '" title="' . $match[2] . '">' . $caption . '</a>' . $match[3];
return $match[1] . '<a href="http://' . $match[2] . '">' . $caption . '</a>' . $match[3];
}
/**
......
......@@ -989,23 +989,23 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
// Converting URLs.
$f = _filter_url('http://www.example.com/', $filter);
$this->assertEqual($f, '<a href="http://www.example.com/" title="http://www.example.com/">http://www.example.com/</a>', t('Converting URLs.'));
$this->assertEqual($f, '<a href="http://www.example.com/">http://www.example.com/</a>', t('Converting URLs.'));
$f = _filter_url('http://www.example.com/?a=1&b=2', $filter);
$this->assertEqual($f, '<a href="http://www.example.com/?a=1&amp;b=2" title="http://www.example.com/?a=1&amp;b=2">http://www.example.com/?a=1&amp;b=2</a>', t('Converting URLs -- ampersands.'));
$this->assertEqual($f, '<a href="http://www.example.com/?a=1&amp;b=2">http://www.example.com/?a=1&amp;b=2</a>', t('Converting URLs -- ampersands.'));
$f = _filter_url('ftp://user:pass@ftp.example.com/dir1/dir2', $filter);
$this->assertEqual($f, '<a href="ftp://user:pass@ftp.example.com/dir1/dir2" title="ftp://user:pass@ftp.example.com/dir1/dir2">ftp://user:pass@ftp.example.com/dir1/dir2</a>', t('Converting URLs -- FTP scheme.'));
$this->assertEqual($f, '<a href="ftp://user:pass@ftp.example.com/dir1/dir2">ftp://user:pass@ftp.example.com/dir1/dir2</a>', t('Converting URLs -- FTP scheme.'));
// Converting domain names.
$f = _filter_url('www.example.com', $filter);
$this->assertEqual($f, '<a href="http://www.example.com" title="www.example.com">www.example.com</a>', t('Converting domain names.'));
$this->assertEqual($f, '<a href="http://www.example.com">www.example.com</a>', t('Converting domain names.'));
$f = _filter_url('<li>www.example.com</li>', $filter);
$this->assertEqual($f, '<li><a href="http://www.example.com" title="www.example.com">www.example.com</a></li>', t('Converting domain names -- domain in a list.'));
$this->assertEqual($f, '<li><a href="http://www.example.com">www.example.com</a></li>', t('Converting domain names -- domain in a list.'));
$f = _filter_url('(www.example.com/dir?a=1&b=2#a)', $filter);
$this->assertEqual($f, '(<a href="http://www.example.com/dir?a=1&amp;b=2#a" title="www.example.com/dir?a=1&amp;b=2#a">www.example.com/dir?a=1&amp;b=2#a</a>)', t('Converting domain names -- domain in parentheses.'));
$this->assertEqual($f, '(<a href="http://www.example.com/dir?a=1&amp;b=2#a">www.example.com/dir?a=1&amp;b=2#a</a>)', t('Converting domain names -- domain in parentheses.'));
// Converting e-mail addresses.
$f = _filter_url('johndoe@example.com', $filter);
......@@ -1049,13 +1049,13 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
// of a sentence, so remove the dot from the link.
// @todo It can also be used at the end of a filename or a query string.
$f = _filter_url('www.example.com.', $filter);
$this->assertEqual($f, '<a href="http://www.example.com" title="www.example.com">www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of a domain name (FQDNs).'));
$this->assertEqual($f, '<a href="http://www.example.com">www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of a domain name (FQDNs).'));
$f = _filter_url('http://www.example.com.', $filter);
$this->assertEqual($f, '<a href="http://www.example.com" title="http://www.example.com">http://www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of an URL (FQDNs).'));
$this->assertEqual($f, '<a href="http://www.example.com">http://www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of an URL (FQDNs).'));
$f = _filter_url('www.example.com/index.php?a=.', $filter);
$this->assertEqual($f, '<a href="http://www.example.com/index.php?a=" title="www.example.com/index.php?a=">www.example.com/index.php?a=</a>.', t('Converting URLs -- do forget about a dot at the end of a query string.'));
$this->assertEqual($f, '<a href="http://www.example.com/index.php?a=">www.example.com/index.php?a=</a>.', t('Converting URLs -- do forget about a dot at the end of a query string.'));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment