From b6fc1d314ee31627e8ba42d7324ea45a97b48fa5 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 18 Apr 2013 14:25:51 +1200 Subject: [PATCH] BUG HTTP will now correctly pass over mailto: links when converting relative links to absolute (e.g. in Emails) --- control/HTTP.php | 1 + tests/control/HTTPTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/control/HTTP.php b/control/HTTP.php index 829c0fda6..7e991b3fa 100644 --- a/control/HTTP.php +++ b/control/HTTP.php @@ -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); }); } diff --git a/tests/control/HTTPTest.php b/tests/control/HTTPTest.php index a7efec132..1503a5592 100644 --- a/tests/control/HTTPTest.php +++ b/tests/control/HTTPTest.php @@ -187,6 +187,18 @@ class HTTPTest extends SapphireTest { }); } + public function testEmailLinks() { + $this->withBaseURL('http://www.silverstripe.org/', function($test){ + + // links + $test->assertEquals( + 'Email Us', + HTTP::absoluteURLs('Email Us') + ); + }); + + } + /** * Run a test while mocking the base url with the provided value * @param string $url The base URL to use for this test