Skip to content

Commit

Permalink
[BUGFIX] Linkvalidator validates linked content elements
Browse files Browse the repository at this point in the history
This patch makes the LinkValidator check typolinks to tt_content
elements like t3://page?uid=x#y by calling InternalLinktype twice, once
for the page as first part of the SoftReferenceIndex and again for the
tt_content element as second part.

Resolves: #85576
Related: #84016
Releases: master, 8.7
Change-Id: I94243e66f5eff38c9a0b0859a85aac48885e38ba
Reviewed-on: https://review.typo3.org/58735
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
patrickbroens authored and bmack committed Oct 27, 2018
1 parent 016a314 commit 574914e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion typo3/sysext/linkvalidator/Classes/Linktype/InternalLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,27 @@ public function checkLink($url, $softRefEntry, $reference)
unset($this->errorParams);
// Only check pages records. Content elements will also be checked
// as we extract the anchor in the next step.
if (strpos($softRefEntry['substr']['recordRef'], 'pages:') !== 0) {
list($table, $uid) = explode(':', $softRefEntry['substr']['recordRef']);
if (!in_array($table, ['pages', 'tt_content'], true)) {
return true;
}
// Defines the linked page and anchor (if any).
if (strpos($url, '#c') !== false) {
$parts = explode('#c', $url);
$page = $parts[0];
$anchor = $parts[1];
} elseif (
$table === 'tt_content'
&& strpos($softRefEntry['row'][$softRefEntry['field']], 't3://') === 0
) {
$parsedTypoLinkUrl = @parse_url($softRefEntry['row'][$softRefEntry['field']]);
if ($parsedTypoLinkUrl['host'] === 'page') {
parse_str($parsedTypoLinkUrl['query'], $query);
if (isset($query['uid'])) {
$page = (int)$query['uid'];
$anchor = (int)$url;
}
}
} else {
$page = $url;
}
Expand Down

0 comments on commit 574914e

Please sign in to comment.