From c68c39df27773173fc7ef884fee8094e7433df68 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 1 May 2015 06:23:49 -0600 Subject: [PATCH] fix for .. page references --- .../Common/Markdown/ParsedownGravTrait.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 0d629be8a..1d7b581dd 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -246,16 +246,23 @@ trait ParsedownGravTrait $page_path = $path_info['dirname']; $filename = ''; - // save the filename if a file is part of the path - $filename_regex = "/([\w\d-_]+\.([a-zA-Z]{2,4}))$/"; - if (preg_match($filename_regex, $full_path, $matches)) { - if ($matches[2] != 'md') { - $filename = '/' . $matches[1]; - } - } else { + + if ($markdown_url == '..') { $page_path = $full_path; + } else { + // save the filename if a file is part of the path + $filename_regex = "/([\w\d-_]+\.([a-zA-Z]{2,4}))$/"; + if (preg_match($filename_regex, $full_path, $matches)) { + if ($matches[2] != 'md') { + $filename = '/' . $matches[1]; + } + } else { + $page_path = $full_path; + } } + + // get page instances and try to find one that fits $instances = $this->pages->instances(); if (isset($instances[$page_path])) {