mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX Fixed publication of multibyte URLSegment in SiteTree->onBeforeWrite(), was wrongly detecting a change and double encoding
This commit is contained in:
parent
77e52d6344
commit
8563322971
@ -1384,7 +1384,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
// If there is no URLSegment set, generate one from Title
|
||||
if((!$this->URLSegment || $this->URLSegment == 'new-page') && $this->Title) {
|
||||
$this->URLSegment = $this->generateURLSegment($this->Title);
|
||||
} else if($this->isChanged('URLSegment')) {
|
||||
} else if($this->isChanged('URLSegment', 2)) {
|
||||
// Do a strict check on change level, to avoid double encoding caused by
|
||||
// bogus changes through forceChange()
|
||||
$filter = URLSegmentFilter::create();
|
||||
$this->URLSegment = $filter->filter($this->URLSegment);
|
||||
// If after sanitising there is no URLSegment, give it a reasonable default
|
||||
|
@ -720,6 +720,26 @@ class SiteTreeTest extends SapphireTest {
|
||||
$sitetree->URLSegment = 'valid';
|
||||
$this->assertTrue($sitetree->validURLSegment(), 'Valid URLSegment values are allowed');
|
||||
}
|
||||
|
||||
public function testURLSegmentMultiByte() {
|
||||
$origAllow = URLSegmentFilter::$default_allow_multibyte;
|
||||
URLSegmentFilter::$default_allow_multibyte = true;
|
||||
$sitetree = new SiteTree();
|
||||
$sitetree->write();
|
||||
|
||||
$sitetree->URLSegment = 'brötchen';
|
||||
$sitetree->write();
|
||||
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
|
||||
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
||||
|
||||
$sitetree->publish('Stage', 'Live');
|
||||
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
|
||||
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
||||
$sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
|
||||
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
|
||||
|
||||
URLSegmentFilter::$default_allow_multibyte = $origAllow;
|
||||
}
|
||||
|
||||
public function testVersionsAreCreated() {
|
||||
$p = new Page();
|
||||
|
Loading…
Reference in New Issue
Block a user