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)

This commit is contained in:
Ingo Schommer 2012-05-08 22:10:44 +02:00
parent 63536af875
commit 77e52d6344
2 changed files with 4 additions and 4 deletions

View File

@ -146,7 +146,7 @@ class ContentController extends Controller {
if(class_exists('Translatable')) Translatable::disable_locale_filter(); if(class_exists('Translatable')) Translatable::disable_locale_filter();
// look for a page with this URLSegment // look for a page with this URLSegment
$child = $this->model->SiteTree->where(sprintf ( $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(); ))->First();
if(class_exists('Translatable')) Translatable::enable_locale_filter(); if(class_exists('Translatable')) Translatable::enable_locale_filter();

View File

@ -94,7 +94,7 @@ class ModelAsController extends Controller implements NestedController {
'SiteTree', 'SiteTree',
sprintf( sprintf(
'"URLSegment" = \'%s\' %s', '"URLSegment" = \'%s\' %s',
Convert::raw2sql($URLSegment), Convert::raw2sql(rawurlencode($URLSegment)),
(SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null) (SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null)
) )
); );
@ -149,7 +149,7 @@ class ModelAsController extends Controller implements NestedController {
* @return SiteTree * @return SiteTree
*/ */
static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) { static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
$URLSegment = Convert::raw2sql($URLSegment); $URLSegment = Convert::raw2sql(rawurlencode($URLSegment));
$useParentIDFilter = SiteTree::nested_urls() && $parentID; $useParentIDFilter = SiteTree::nested_urls() && $parentID;