mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1768 from tractorcow/3.1-http-mail-fixes
BUG HTTP incorrectly converts mailto links to absolute urls
This commit is contained in:
commit
6e0fa5db45
@ -42,6 +42,7 @@ class HTTP {
|
||||
public static function absoluteURLs($html) {
|
||||
$html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html);
|
||||
return HTTP::urlRewriter($html, function($url) {
|
||||
if(stripos($url, 'mailto:') === 0) return $url;
|
||||
return Director::absoluteURL($url, true);
|
||||
});
|
||||
}
|
||||
|
@ -187,6 +187,18 @@ class HTTPTest extends SapphireTest {
|
||||
});
|
||||
}
|
||||
|
||||
public function testEmailLinks() {
|
||||
$this->withBaseURL('http://www.silverstripe.org/', function($test){
|
||||
|
||||
// links
|
||||
$test->assertEquals(
|
||||
'<a href=\'mailto:admin@silverstripe.org\'>Email Us</a>',
|
||||
HTTP::absoluteURLs('<a href=\'mailto:admin@silverstripe.org\'>Email Us</a>')
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a test while mocking the base url with the provided value
|
||||
* @param string $url The base URL to use for this test
|
||||
|
Loading…
Reference in New Issue
Block a user