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

View File

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