mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #5259 RedirectorPage and HtmlEditorField TinyMCE integration now prefixes http:// if no prefix is found (from r101668)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112016 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5aa012335a
commit
7d3d9a005e
@ -104,6 +104,15 @@ class RedirectorPage extends Page {
|
||||
}
|
||||
}
|
||||
|
||||
function onBeforeWrite() {
|
||||
parent::onBeforeWrite();
|
||||
|
||||
// Prefix the URL with "http://" if no prefix is found
|
||||
if($this->ExternalURL && (strpos($this->ExternalURL, '://') === false)) {
|
||||
$this->ExternalURL = 'http://' . $this->ExternalURL;
|
||||
}
|
||||
}
|
||||
|
||||
function getCMSFields() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/RedirectorPage.js");
|
||||
|
||||
@ -170,4 +179,3 @@ class RedirectorPage_Controller extends Page_Controller {
|
||||
"</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
4
javascript/tiny_mce_improvements.js
vendored
4
javascript/tiny_mce_improvements.js
vendored
@ -200,6 +200,10 @@ LinkForm.prototype = {
|
||||
case 'external':
|
||||
default:
|
||||
href = this.elements.external.value;
|
||||
// Prefix the URL with "http://" if no prefix is found
|
||||
if(href.indexOf('://') == -1) {
|
||||
href = 'http://' + href;
|
||||
}
|
||||
if($('Form_EditorToolbarLinkForm_TargetBlank')) {
|
||||
if($('Form_EditorToolbarLinkForm_TargetBlank').checked) target = '_blank';
|
||||
}
|
||||
|
@ -43,6 +43,11 @@ class RedirectorPageTest extends FunctionalTest {
|
||||
$response = $this->get(Director::makeRelative($page->Link()));
|
||||
$this->assertEquals(Director::baseURL() . "redirection-dest/", $response->getHeader("Location"));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
function testExternalURLGetsPrefixIfNotSet() {
|
||||
$page = $this->objFromFixture('RedirectorPage', 'externalnoprefix');
|
||||
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite has prefixed with http');
|
||||
$page->write();
|
||||
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite will not double prefix if written again!');
|
||||
}
|
||||
}
|
@ -18,6 +18,11 @@ RedirectorPage:
|
||||
Title: Bad External
|
||||
RedirectionType: External
|
||||
URLSegment: bad-external
|
||||
externalnoprefix:
|
||||
Title: External no prefix
|
||||
RedirectionType: External
|
||||
URLSegment: external-no-prefix
|
||||
ExternalURL: google.com
|
||||
badinternal:
|
||||
Title: Bad Internal
|
||||
RedirectionType: Internal
|
||||
|
Loading…
Reference in New Issue
Block a user