joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

Global Joomla Text Filtering Setting Being Ignored by TinyMCE #42117

Closed toby07801 closed 8 months ago

toby07801 commented 1 year ago

Steps to reproduce the issue

OR

THEN

Open a new Joomla Article, switch to TinyMCE code view and paste in some custom html with custom element attributes such as this sample code:

<div class="el-item">
<a class="uk-box-shadow-small uk-box-shadow-hover-medium tm-box-decoration-secondary uk-inline uk-link-toggle" href="/images/TSLA_W.jpg" data-type="image" data-caption="<h4 class='uk-margin-remove'>Figure 1</h4>" role="button">    
<div class="uk-inline-clip">        
<picture><img src="/templates/cache/f4/TSLA.jpeg" width="3836" height="2025" alt="" loading="lazy" class="el-image uk-transition-opaque"></picture>
<div class="uk-position-bottom-left uk-overlay-default"><div class="uk-overlay uk-padding-small uk-margin-remove-first-child"><h5 class="el-title uk-h5 uk-margin-top uk-margin-remove-bottom"><span class="uk-link-heading">Figure 1</span></h5></div>
</div>
</div>
</a>
</div>

Expected result

Page is saved correctly and code remains unchanged since I have disabled Joomla Filtering in Global Settings for the Super Users group which I am part of, and since I am using either the Joomla Filtering mode (None) option in TinyMCE, or attempting to use its own settings by overriding the TinyMCE native filters and allowing all elements by using the wildcard *[*] in order to prevent it from filtering any potentially disallowed elements or attributes.

Actual result

On save of the article, or by toggling between code view and WYSIWYG mode, then back to code view, the resulting code is heavily stripped back as shown below, and the html no longer functions or renders as intended.

<div class="el-item">
<div class="uk-inline-clip"><picture><img src="templates/cache/f4/TSLA.jpeg" width="3836" height="2025" alt="" loading="lazy" class="el-image uk-transition-opaque" /></picture>
<div class="uk-position-bottom-left uk-overlay-default">
<div class="uk-overlay uk-padding-small uk-margin-remove-first-child">
<h5 class="el-title uk-h5 uk-margin-top uk-margin-remove-bottom"><span class="uk-link-heading">Figure 1</span></h5>
</div>
</div>
</div>
</div>

System information (as much as possible)

PHP Built On Linux 5.15.0-86-generic #96-Ubuntu SMP Wed Sep 20 08:23:49 UTC 2023 x86_64 Database Type mysql Database Version 10.6.12-MariaDB-0ubuntu0.22.04.1 Database Collation utf8mb3_general_ci Database Connection Collation utf8mb4_general_ci Database Connection Encryption None Database Server Supports Connection Encryption No PHP Version 8.2.11 Web Server Apache WebServer to PHP Interface fpm-fcgi Joomla! Version Joomla! 4.3.4 Stable [ Bora ] 22-August-2023 16:00 GMT User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36

Additional comments

A previous post (Issue #35535) has a very similar problem description and I looked at this in detail, but the solution there was that the changes were simply being applied to the wrong "TinyMCE Set", which is definitely not where I have been going wrong and I double and triple check this.

brianteeman commented 1 year ago

Turning the text filters off doesn't stop tinymce from preventing invalid html.

There is nothing that joomla can do to allow you to paste this html. You can test it yourself on a pure tinymce demo here https://www.tiny.cloud/docs/demo/classic/ where the effect is the same.

The slightly good news for you is that tinymce v6 does its job slightly differently and corrects your code in a better way (for you). You can test this at https://www.tiny.cloud/docs/tinymce/6/classic-demo/

Tinymce v6 is in Joomla 5 which is scheduled to be released in a week.

toby07801 commented 1 year ago

Thanks for the update. That does look promising.

Is there no way to tell TinyMCE to not do any code filtering for Super Users AT ALL that anybody is aware of? That seems like a fairly straightforward thing to have as a feature as it essentially just means "do absolutely nothing" to the code.

I'm not sure I understand at all what the purpose of having an "extended allowed" field is, which their documentation states can accept wildcards, if this is then just completely ignored. Similarly, what is the purpose of the switch "Use Joomla Filter" if again this setting appears to not be respected, and it just does its own thing without as much as a warning that code has been removed.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42117.

brianteeman commented 1 year ago

Is there no way to tell TinyMCE to not do any code filtering for Super Users AT ALL that anybody is aware of?

No.

joomdonation commented 8 months ago

Closing this issue because this is handled by TinyMCE and Joomla could not do anything change this behavior as pointed out by @brianteeman