Skip to content

Commit

Permalink
[BUGFIX] Enforce setCopyMode in clipboard
Browse files Browse the repository at this point in the history
The clipboard component features helper methods,
which generate a URL to update the clipboard
state with new elements. Those are used in
recordlist and filelist.

Previously the "setCopyMode" parameter was
only set in case the element should be "copied".
This then might lead to no "mode" set in the
clipboardData at all. Like other modules
already do, the helper methods do now always
set the "setCopyMode" parameter to enforce
the generation of the "mode" key in the
clipboardData.

Anyways, an access of the "mode" in the page
module is secured by a null collapse operator.

Resolves: #95536
Releases: master
Change-Id: I0799f711cd3ab8b6be702b62ba26d974d46da2d0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71504
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
ochorocho authored and lolli42 committed Oct 19, 2021
1 parent 2e1d68b commit 6e3ec7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions typo3/sysext/backend/Classes/Clipboard/Clipboard.php
Expand Up @@ -515,11 +515,12 @@ protected function linkItemText(string $itemText, $reference, bool $isRequestedT
*/
public function selUrlDB(string $table, int $uid, bool $copy = false, bool $deselect = false): string
{
$CB = ['el' => [$table . '|' . $uid => $deselect ? 0 : 1]];
if ($copy) {
$CB['setCopyMode'] = 1;
}
return $this->buildUrl(['CB' => $CB]);
return $this->buildUrl(['CB' => [
'el' => [
$table . '|' . $uid => $deselect ? 0 : 1,
],
'setCopyMode' => (int)$copy,
]]);
}

/**
Expand All @@ -532,15 +533,12 @@ public function selUrlDB(string $table, int $uid, bool $copy = false, bool $dese
*/
public function selUrlFile(string $path, bool $copy = false, bool $deselect = false): string
{
$CB = [
return $this->buildUrl(['CB' => [
'el' => [
'_FILE|' . md5($path) => $deselect ? '' : $path,
],
];
if ($copy) {
$CB['setCopyMode'] = 1;
}
return $this->buildUrl(['CB' => $CB]);
'setCopyMode' => (int)$copy,
]]);
}

/**
Expand Down
Expand Up @@ -645,7 +645,7 @@ protected function initializeClipboard(ServerRequestInterface $request): void
function(Paste) {
Paste.itemOnClipboardUid = ' . $pasteItem . ';
Paste.itemOnClipboardTitle = ' . GeneralUtility::quoteJSvalue($pasteTitle) . ';
Paste.copyMode = ' . GeneralUtility::quoteJSvalue($clipboard->clipData['normal']['mode']) . ';
Paste.copyMode = ' . GeneralUtility::quoteJSvalue($clipboard->clipData['normal']['mode'] ?? '') . ';
}');
}
}
Expand Down

0 comments on commit 6e3ec7e

Please sign in to comment.