Cms: Craft.initUiElements() adds target/rel attributes to all outbound links, not just those in the given container element

Created on 16 Mar 2021  路  2Comments  路  Source: craftcms/cms

Description

Craft 3.6.7 (specifically commit https://github.com/craftcms/cms/commit/b06379eb026a095a099792a5f60f85f9655d9efd) moves some code into Craft.initUiElements() which selects links and adds target/rel attributes to outbound links to open them in a new window. However, it selects all links on the page, not just those in the $container passed to Craft.initUiElements(). This can cause unwanted side-effects when the Craft control panel is on a separate subdomain to the front-end, particularly regarding plugins which make use of Craft.initUiElements() and Redactor fields with a link to an entry. For example, the attributes can potentially get added to all such links on an element edit page on page load if the field layout contains a Neo field (originally reported at spicywebau/craft-neo#433), or when adding a new row to a Super Table field.

Steps to reproduce

  1. Access the control panel on a separate subdomain
  2. Call Craft.initUiElements('footer') on an entry edit page with a Redactor field, containing a link to another entry that is not set to open in a new tab
  3. View the HTML of the Redactor field and see that the target and rel attributes have been added to the link

Additional info

  • Craft version: 3.6.7 - 3.6.10
  • PHP version: 8.0.2
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions: Redactor 2.8.5, Neo 2.9.2, Super Table 2.6.7
bug

Most helpful comment

Craft 3.6.11 is out now with that fix.

All 2 comments

Thank for reporting that! Fixed for the next release.

Craft 3.6.11 is out now with that fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

angrybrad picture angrybrad  路  3Comments

richhayler picture richhayler  路  3Comments

brandonkelly picture brandonkelly  路  3Comments

michaelhue picture michaelhue  路  3Comments

michel-o picture michel-o  路  3Comments