Skip to content

Commit

Permalink
fix: php warnings in JumpurlController
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Neyman committed Jun 8, 2023
1 parent a4922dd commit 6a06b25
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Classes/Middleware/JumpurlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($this->shouldProcess()) {
$mailId = (int)$this->request->getQueryParams()['mid'];
$submittedRecipient = isset($this->request->getQueryParams()['rid']) ? (string)$this->request->getQueryParams()['rid'] : '';
$submittedAuthCode = $this->request->getQueryParams()['aC'];
$jumpurl = $this->request->getQueryParams()['jumpurl'];
$submittedAuthCode = $this->request->getQueryParams()['aC'] ?? '';
$jumpurl = $this->request->getQueryParams()['jumpurl'] ?? '';

$urlId = 0;
if (MathUtility::canBeInterpretedAsInteger($jumpurl)) {
Expand Down Expand Up @@ -179,25 +179,28 @@ protected function initDirectMailRecord(int $mailId): void
* Fetches the target url from the direct mail record
*
* @param int $targetIndex
* @return string|null
* @return string
*/
protected function getTargetUrl(int $targetIndex): ?string
protected function getTargetUrl(int $targetIndex): string
{
$targetUrl = null;
$targetUrl = '';

if (!empty($this->directMailRecord)) {
$mailContent = unserialize(
base64_decode((string)$this->directMailRecord['mailContent']),
['allowed_classes' => false]
);
if ($targetIndex >= 0) {
// Link (number)
$this->responseType = self::RESPONSE_TYPE_HREF;
$targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef'];
} else {
// Link (number, plaintext)
$this->responseType = self::RESPONSE_TYPE_PLAIN;
$targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)];

if(is_array($mailContent)) {
if ($targetIndex >= 0) {
// Link (number)
$this->responseType = self::RESPONSE_TYPE_HREF;
$targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef'];
} else {
// Link (number, plaintext)
$this->responseType = self::RESPONSE_TYPE_PLAIN;
$targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)];
}
}
$targetUrl = htmlspecialchars_decode(urldecode($targetUrl));
}
Expand Down

0 comments on commit 6a06b25

Please sign in to comment.