From 77e52d6344bca19eeebff703d131602f31a9c342 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 8 May 2012 22:10:44 +0200 Subject: [PATCH] ENHANCEMENT Url encoding URLSegments before matching them against database records in ModelAsController, to match behaviour of SiteTree with URLSegmentFilter::$default_allow_multibyte=true. Not an API change because all encodable characters have been removed by the default URLSegmentFilter already (see http://www.w3.org/International/articles/idn-and-iri/#iriproblem) --- code/controllers/ContentController.php | 2 +- code/controllers/ModelAsController.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index f3104b5a..0aa02009 100644 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -146,7 +146,7 @@ class ContentController extends Controller { if(class_exists('Translatable')) Translatable::disable_locale_filter(); // look for a page with this URLSegment $child = $this->model->SiteTree->where(sprintf ( - "\"ParentID\" = %s AND \"URLSegment\" = '%s'", $this->ID, Convert::raw2sql($action) + "\"ParentID\" = %s AND \"URLSegment\" = '%s'", $this->ID, Convert::raw2sql(rawurlencode($action)) ))->First(); if(class_exists('Translatable')) Translatable::enable_locale_filter(); diff --git a/code/controllers/ModelAsController.php b/code/controllers/ModelAsController.php index 83eea1ed..f5455d8e 100644 --- a/code/controllers/ModelAsController.php +++ b/code/controllers/ModelAsController.php @@ -87,14 +87,14 @@ class ModelAsController extends Controller implements NestedController { if(!$URLSegment = $request->param('URLSegment')) { throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.'); } - + // Find page by link, regardless of current locale settings if(class_exists('Translatable')) Translatable::disable_locale_filter(); $sitetree = DataObject::get_one( 'SiteTree', sprintf( '"URLSegment" = \'%s\' %s', - Convert::raw2sql($URLSegment), + Convert::raw2sql(rawurlencode($URLSegment)), (SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null) ) ); @@ -149,7 +149,7 @@ class ModelAsController extends Controller implements NestedController { * @return SiteTree */ static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) { - $URLSegment = Convert::raw2sql($URLSegment); + $URLSegment = Convert::raw2sql(rawurlencode($URLSegment)); $useParentIDFilter = SiteTree::nested_urls() && $parentID;