From 3f1661965bf4004230f49ea0a1bc8c4f897c6a88 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 18 May 2015 18:54:08 +0200 Subject: [PATCH 1/4] Fix for issue #194 - query string handling --- system/src/Grav/Common/Uri.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index c4297bc20..f904d28bb 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -74,15 +74,27 @@ class Uri { $config = Grav::instance()['config']; + // resets + $this->paths = []; + $this->params = []; + $this->query = []; + + // get any params and remove them $uri = str_replace($this->root, '', $this->url); - // reset params - $this->params = []; - // process params $uri = $this->processParams($uri, $config->get('system.param_sep')); + // split the URL and params + $bits = parse_url($uri); + + // process query string + if (isset($bits['query'])) { + parse_str($bits['query'], $this->query); + $uri = $bits['path']; + } + // remove the extension if there is one set $parts = pathinfo($uri); @@ -96,19 +108,7 @@ class Uri // set the new url $this->url = $this->root . $uri; - - // split into bits - $this->bits = parse_url($uri); - - $this->query = array(); - if (isset($this->bits['query'])) { - parse_str($this->bits['query'], $this->query); - } - - $path = $this->bits['path']; - - $this->paths = array(); - $this->path = $path; + $this->path = $uri; $this->content_path = trim(str_replace($this->base, '', $this->path), '/'); if ($this->content_path != '') { $this->paths = explode('/', $this->content_path); From 1147516dcca93ece48dd7c32be319e3ea99b5026 Mon Sep 17 00:00:00 2001 From: Gert Date: Wed, 20 May 2015 16:07:39 +0200 Subject: [PATCH 2/4] fix for path detection on windows [fix #194] --- system/src/Grav/Common/Uri.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index f904d28bb..2b2da933a 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -102,7 +102,7 @@ class Uri $this->basename = $parts['basename']; if (preg_match("/\.(".$config->get('system.pages.types').")$/", $parts['basename'])) { - $uri = rtrim($parts['dirname'], '/').'/'.$parts['filename']; + $uri = rtrim(str_replace(DIRECTORY_SEPARATOR, DS, $parts['dirname']), DS). '/' .$parts['filename']; $this->extension = $parts['extension']; } From 7afef9073c85996c1b17723346f6f7ba6ab223d4 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 21 May 2015 22:44:11 +0200 Subject: [PATCH 3/4] fix for dot files --- system/src/Grav/Common/Page/Pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index ac0e9e70f..b4d81daba 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -557,7 +557,7 @@ class Pages $last_modified = $modified; } - if (Utils::endsWith($name, CONTENT_EXT)) { + if (preg_match('/^[^.].*'.CONTENT_EXT.'$/um', $name)) { $page->init($file); $content_exists = true; From f779fc57df787583701dd8c8e02c3dc53c622fd7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 22 May 2015 11:43:23 +0300 Subject: [PATCH 4/4] removed unneeded flags from reggae --- system/src/Grav/Common/Page/Pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index b4d81daba..826618b70 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -557,7 +557,7 @@ class Pages $last_modified = $modified; } - if (preg_match('/^[^.].*'.CONTENT_EXT.'$/um', $name)) { + if (preg_match('/^[^.].*'.CONTENT_EXT.'$/', $name)) { $page->init($file); $content_exists = true;