mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #402 from micmania1/fix-376-url
FIX #376 allow multibyte chars in url segment
This commit is contained in:
commit
a21b50333d
@ -36,6 +36,12 @@ class URLSegmentExtension extends DataExtension
|
|||||||
{
|
{
|
||||||
$filter = new URLSegmentFilter();
|
$filter = new URLSegmentFilter();
|
||||||
|
|
||||||
|
// Setting this to on. Because of the UI flow, it would be quite a lot of work
|
||||||
|
// to support turning this off. (ie. the add by title flow would not work).
|
||||||
|
// If this becomes a problem we can approach it then.
|
||||||
|
// @see https://github.com/silverstripe/silverstripe-blog/issues/376
|
||||||
|
$filter->setAllowMultibyte(true);
|
||||||
|
|
||||||
$this->owner->URLSegment = $filter->filter($this->owner->Title);
|
$this->owner->URLSegment = $filter->filter($this->owner->Title);
|
||||||
|
|
||||||
if (is_int($increment)) {
|
if (is_int($increment)) {
|
||||||
|
@ -52,6 +52,22 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
$this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count');
|
$this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://github.com/silverstripe/silverstripe-blog/issues/376
|
||||||
|
*/
|
||||||
|
public function testAllowMultibyteUrlSegment()
|
||||||
|
{
|
||||||
|
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
||||||
|
$cat = new BlogCategory();
|
||||||
|
$cat->BlogID = $blog->ID;
|
||||||
|
$cat->Title = 'تست';
|
||||||
|
$cat->write();
|
||||||
|
// urlencoded
|
||||||
|
$this->assertEquals('%D8%AA%D8%B3%D8%AA', $cat->URLSegment);
|
||||||
|
$link = Controller::join_links($cat->Blog()->Link(), 'category', '%D8%AA%D8%B3%D8%AA');
|
||||||
|
$this->assertEquals($link, $cat->getLink());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCanView()
|
public function testCanView()
|
||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
@ -52,6 +52,22 @@ class BlogTagTest extends FunctionalTest
|
|||||||
$this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
|
$this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://github.com/silverstripe/silverstripe-blog/issues/376
|
||||||
|
*/
|
||||||
|
public function testAllowMultibyteUrlSegment()
|
||||||
|
{
|
||||||
|
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
||||||
|
$tag = new BlogTag();
|
||||||
|
$tag->BlogID = $blog->ID;
|
||||||
|
$tag->Title = 'تست';
|
||||||
|
$tag->write();
|
||||||
|
// urlencoded
|
||||||
|
$this->assertEquals('%D8%AA%D8%B3%D8%AA', $tag->URLSegment);
|
||||||
|
$link = Controller::join_links($tag->Blog()->Link(), 'tag', '%D8%AA%D8%B3%D8%AA');
|
||||||
|
$this->assertEquals($link, $tag->getLink());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first blog can be viewed by anybody.
|
* The first blog can be viewed by anybody.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user