Skip to content

Commit

Permalink
Don't pass along x-craft-(live-)preview params if unverified
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 29, 2024
1 parent 4dc0eed commit ca91aa3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
### System
- MySQL mutex locks and PHP session names are now namespaced using the application ID combined with the environment name. ([#15313](https://github.com/craftcms/cms/issues/15313))
- `x-craft-preview` and `x-craft-live-preview` params are now hashed, and `craft\web\Request::getIsPreview()` will only return `true` if the param validates. ([#15605](https://github.com/craftcms/cms/discussions/15605))
- Generated URLs no longer include `x-craft-preview` or `x-craft-live-preview` query string params based on the requested URL, if either were set to an unverified string. ([#15605](https://github.com/craftcms/cms/discussions/15605))
- Updated Twig to 3.12. ([#15568](https://github.com/craftcms/cms/discussions/15568))
6 changes: 5 additions & 1 deletion src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ private static function _createUrl(
if ($addToken && !isset($params[$generalConfig->tokenParam]) && ($token = $request->getToken()) !== null) {
$params[$generalConfig->tokenParam] = $token;
}
if (!isset($params['x-craft-preview']) && !isset($params['x-craft-live-preview'])) {
if (
!isset($params['x-craft-preview']) &&
!isset($params['x-craft-live-preview']) &&
$request->getIsPreview()
) {
if (($previewToken = $request->getQueryParam('x-craft-preview')) !== null) {
$params['x-craft-preview'] = $previewToken;
} elseif (($previewToken = $request->getQueryParam('x-craft-live-preview')) !== null) {
Expand Down

0 comments on commit ca91aa3

Please sign in to comment.