Project

General

Profile

Actions

Bug #103698

closed

RTE does not allow empty attributes for the tag "a"

Added by Timo Webler 7 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
-
Start date:
2024-04-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The method \TYPO3\CMS\Core\Html\RteHtmlParser::TS_links_db remove all empty attributes from the tag "a".

This is needed to set the attribute download,. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download

Possible solution.

Index: sysext/core/Classes/Html/RteHtmlParser.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sysext/core/Classes/Html/RteHtmlParser.php b/sysext/core/Classes/Html/RteHtmlParser.php
--- a/sysext/core/Classes/Html/RteHtmlParser.php    
+++ b/sysext/core/Classes/Html/RteHtmlParser.php    (date 1713779033389)
@@ -356,7 +356,7 @@
                     $tagAttributes['href'] = $linkInformation['href'] ?? $tagAttributes['href'];
                 }

-                $blockSplit[$k] = '<a ' . GeneralUtility::implodeAttributes($tagAttributes, true) . '>'
+                $blockSplit[$k] = '<a ' . GeneralUtility::implodeAttributes($tagAttributes, true, true) . '>'
                     . $this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])) . '</a>';
             }
         }
Actions #1

Updated by Gerrit Code Review 7 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83953

Actions #2

Updated by Gerrit Code Review 7 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83953

Actions #3

Updated by Timo Webler 7 months ago

Sorry for the late addional infos. For the frontend rendering the following changes also nessesary.

Index: sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
--- a/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php    
+++ b/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php    (date 1713792053044)
@@ -4880,7 +4880,7 @@
             $aTagParams = GeneralUtility::get_tag_attributes($finalTagParts['aTagParams'], true);
             if (isset($aTagParams['href'])) {
                 unset($aTagParams['href']);
-                $finalTagParts['aTagParams'] = GeneralUtility::implodeAttributes($aTagParams, true);
+                $finalTagParts['aTagParams'] = GeneralUtility::implodeAttributes($aTagParams, true, true);
             }
         }

@@ -4960,7 +4960,7 @@
         $finalTagAttributes = array_merge($tagAttributes, GeneralUtility::get_tag_attributes($finalTagParts['aTagParams']));
         $finalTagAttributes = $this->addSecurityRelValues($finalTagAttributes, $this->lastTypoLinkResult->getTarget(), $tagAttributes['href']);
         $this->lastTypoLinkResult = $this->lastTypoLinkResult->withAttributes($finalTagAttributes);
-        $finalAnchorTag = '<a ' . GeneralUtility::implodeAttributes($finalTagAttributes) . '>';
+        $finalAnchorTag = '<a ' . GeneralUtility::implodeAttributes($finalTagAttributes, false, true) . '>';

         $this->lastTypoLinkTarget = $this->lastTypoLinkResult->getTarget();
         // kept for backwards-compatibility in hooks

Actions #4

Updated by Gerrit Code Review 7 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83953

Actions #5

Updated by Gerrit Code Review 7 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83953

Actions #6

Updated by Gerrit Code Review 7 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83973

Actions #7

Updated by Oliver Bartsch 7 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF