mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX: Comment URL field check is now case insenstive. Included tests for various protocols. PATCH via simon_w. Ticket #4776 (from r97016)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102706 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
afd8faf567
commit
0b6f99df14
@ -150,16 +150,11 @@ class PageComment extends DataObject {
|
||||
$url = $this->CommenterURL;
|
||||
|
||||
if($url) {
|
||||
if(substr($url, 0, 8) != 'https://') {
|
||||
if(substr($url, 0, 7) != 'http://') {
|
||||
$url = $this->CommenterURL = 'http://' . $url;
|
||||
}
|
||||
if(strtolower(substr($url, 0, 8)) != 'https://' && strtolower(substr($url, 0, 7)) != 'http://') {
|
||||
$this->CommenterURL = 'http://' . $url;
|
||||
}
|
||||
}
|
||||
|
||||
$this->CommenterURL = $url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,5 +27,21 @@ class PageCommentsTest extends FunctionalTest {
|
||||
$thirdComments = DataObject::get('PageComment', 'ParentID = '.$third->ID);
|
||||
$this->assertEquals($thirdComments->Count(), 3);
|
||||
}
|
||||
|
||||
function testCommenterURLWrite() {
|
||||
$comment = new PageComment();
|
||||
// We only care about the CommenterURL, so only set that
|
||||
// Check a http and https URL. Add more test urls here as needed.
|
||||
$protocols = array(
|
||||
'Http',
|
||||
'Https',
|
||||
);
|
||||
$url = '://example.com';
|
||||
foreach($protocols as $protocol) {
|
||||
$comment->CommenterURL = $protocol . $url;
|
||||
// The protocol should stay as if, assuming it is valid
|
||||
$comment->write();
|
||||
$this->assertEquals($comment->CommenterURL, $protocol . $url, $protocol . ':// is a valid protocol');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user