Merge pull request #402 from micmania1/fix-376-url

FIX #376 allow multibyte chars in url segment
This commit is contained in:
Damian Mooyman 2016-06-29 17:51:22 +12:00 committed by GitHub
commit a21b50333d
3 changed files with 38 additions and 0 deletions

View File

@ -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)) {

View File

@ -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();

View File

@ -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.
*/