Skip to content

Commit

Permalink
Fixed token creation issue with Uri params like /id:3
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Nov 17, 2017
1 parent 72f3a01 commit cb4147a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Uri: Encode user and password to prevent issues in browsers
* Fixed "Invalid AJAX response" When using Built-in PHP Webserver in Windows [#1258](https://github.com/getgrav/grav-plugin-admin/issues/1258)
* Remove support for `config.user`, it was broken and bad practise
* Make sure that `clean cache` uses valid path [#1745](https://github.com/getgrav/grav/pull/1745)
* Fixed token creation issue with `Uri` params like `/id:3`

# v1.3.8
## 10/26/2017
Expand Down
9 changes: 9 additions & 0 deletions system/src/Grav/Common/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,20 @@ public static function convertUrlOld(Page $page, $markdown_url, $type = 'link',
*/
public static function addNonce($url, $action, $nonceParamName = 'nonce')
{
$fake = $url && $url[0] === '/';

if ($fake) {
$url = 'http://domain.com' . $url;
}
$uri = new static($url);
$parts = $uri->toArray();
$nonce = Utils::getNonce($action);
$parts['params'] = (isset($parts['params']) ? $parts['params'] : []) + [$nonceParamName => $nonce];

if ($fake) {
unset($parts['scheme'], $parts['host']);
}

return static::buildUrl($parts);
}

Expand Down

0 comments on commit cb4147a

Please sign in to comment.