mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX #376 allow multibyte chars in url segment
This commit is contained in:
parent
c1ae82b74b
commit
e4c3b879e8
@ -36,6 +36,12 @@ class URLSegmentExtension extends DataExtension
|
||||
{
|
||||
$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);
|
||||
|
||||
if (is_int($increment)) {
|
||||
|
@ -52,6 +52,22 @@ class BlogCategoryTest extends FunctionalTest
|
||||
$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()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
@ -52,6 +52,22 @@ class BlogTagTest extends FunctionalTest
|
||||
$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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user