diff --git a/control/HTTP.php b/control/HTTP.php
index f6d578b1a..03f7cdbcb 100644
--- a/control/HTTP.php
+++ b/control/HTTP.php
@@ -62,7 +62,10 @@ 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;
+ //no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":")
+ if(preg_match('/^\w+:/', $url)){
+ return $url;
+ }
return Director::absoluteURL($url, true);
});
}
diff --git a/tests/control/HTTPTest.php b/tests/control/HTTPTest.php
index 1503a5592..10b29940a 100644
--- a/tests/control/HTTPTest.php
+++ b/tests/control/HTTPTest.php
@@ -173,6 +173,14 @@ class HTTPTest extends SapphireTest {
HTTP::absoluteURLs('
SS Blog
')
);
+ //check dot segments
+ // Assumption: dots are not removed
+ //if they were, the url should be: http://www.silverstripe.org/abc
+ $test->assertEquals(
+ 'Test',
+ HTTP::absoluteURLs('Test')
+ );
+
// image
$test->assertEquals(
'',
@@ -187,16 +195,33 @@ class HTTPTest extends SapphireTest {
});
}
- public function testEmailLinks() {
+ /**
+ * Make sure URI schemes are not rewritten
+ */
+ public function testURISchemes() {
$this->withBaseURL('http://www.silverstripe.org/', function($test){
-
- // links
+
+ // mailto
$test->assertEquals(
'Email Us',
- HTTP::absoluteURLs('Email Us')
+ HTTP::absoluteURLs('Email Us'),
+ 'Email links are not rewritten'
);
+
+ // data uri
+ $test->assertEquals(
+ '',
+ HTTP::absoluteURLs(''),
+ 'Data URI links are not rewritten'
+ );
+
+ // call
+ $test->assertEquals(
+ '',
+ HTTP::absoluteURLs(''),
+ 'Call to links are not rewritten'
+ );
});
-
}
/**