No Code Attached Yet bug
avatar niosme
niosme
27 Apr 2023

Steps to reproduce the issue

Set tinymce plugin to use joomla filters.
On joomla filters from global configuration set to no filter.

Expected result

After save on editor e.g. custom module it cleans up my code based on html4. No even in html5.
I thought It should have not change my code at all.

e.g.
<a href="blabla.gr"><div>blabla</div><div>test</div></a>

Actual result

Changes it based on html4 which was not allowed.But in html5 we allowed to do that.

The result after saving is that:

<div>blabla</div>
<div>test</div>

Also it comments out <?php echo 'hey'?> and turns it into <!--?php echo 'heyy';?--> but i can write <script>alert('hey');</script> code normally.

System information (as much as possible)

Joomla 4.3

Additional comments

Am i doing something wrong or there is an option from settings to allow all this?
Btw it strips it like it uses htm4.

Thanks a lot <3

avatar niosme niosme - open - 27 Apr 2023
avatar joomla-cms-bot joomla-cms-bot - change - 27 Apr 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Apr 2023
avatar niosme niosme - change - 27 Apr 2023
The description was changed
avatar niosme niosme - edited - 27 Apr 2023
avatar niosme niosme - change - 27 Apr 2023
The description was changed
avatar niosme niosme - edited - 27 Apr 2023
avatar brianteeman
brianteeman - comment - 27 Apr 2023

<a href="blabla.gr"><div>blabla</div><div>test</div></a>

The changes made to that line are being made by tinymce - not joomla. You can confirm that by testing one of their own demos. Nothing we can do about that

avatar dgrammatiko
dgrammatiko - comment - 27 Apr 2023

<a href="blabla.gr"><div>blabla</div><div>test</div></a>

This is NOT a valid value for the link tag according to the HTML specs: https://html.spec.whatwg.org/multipage/links.html#introduction-2 so tinyMCE rightfully discards the element. You can use <a href="https://blabla.gr"><div>blabla</div><div>test</div></a> or maybe (I haven't tested it) <a href="//blabla.gr"><div>blabla</div><div>test</div></a>

Also it comments out and turns it into but i can write <script>alert('hey');</script> code normally.

The php tags converted to comments actually is a security enforced by Joomla. Finally consider NOT writing style or script elements inside your articles, instead create a textarea custom field for each type and in the layout pass the value through the Joomla API: eg \Joomla\CMS\Factory::getDocument()->getWebAssetManager()->addInlineScript($scriptContent, $options, $attributes);...

avatar niosme
niosme - comment - 28 Apr 2023

https://www.tutorialspoint.com/is-wrapping-a-div-inside-an-anchor-tag-valid-code

But why tinymce keep removing and chaning the code when its setted to be handled by joomla?
How we can prevent from doing any changes?

It also changes the linkes from "/" to the domain link e.g. "myexample.com".
when i type "/index.php" it will always turn it to "myexample.com/index.php" by tinymce.

I changes from the tinymce plugin paths from relevant to absolute but behaviour stays the same.

When we make a demo site and we are going to transfer it, we will have to change every path from the begging which is very annyoing.

How we can prevent tinymce from changes like those to happen?

avatar dgrammatiko
dgrammatiko - comment - 28 Apr 2023

when i type "/index.php" it will always turn it to "myexample.com/index.php" by tinymce.

That's Joomla, not tinyMCE that applies this:

if (strpos($buffer, 'href="' . $prefix . 'index.php?') !== false) {
preg_match_all('#href="' . $prefix . 'index.php\?([^"]+)"#m', $buffer, $matches);
foreach ($matches[1] as $urlQueryString) {
$buffer = str_replace(
'href="' . $prefix . 'index.php?' . $urlQueryString . '"',
'href="' . trim($prefix, '/') . Route::_('index.php?' . $urlQueryString) . '"',
$buffer
);
}
$this->checkBuffer($buffer);

In sort these links are manipulated at run time so when you will transfer the site the links will point to the right domain. There's nothing wrong on this behaviour, actually it's far better than the hardcoding version of wp, where you have to do a search and replace manually if the domain changes...

avatar niosme
niosme - comment - 28 Apr 2023

It replaces it before saving the custom module or article on backend.When you switch from source code to editor it already changed that.

Because i have already done a transfer i can confirm that it does not changes the path. after transfer dynamically.

Also html5 allows inside divs in a tags and it also pass succesfully throw all w3 checks if its a div inside an a tag.

avatar niosme niosme - change - 28 Apr 2023
Title
TinyMce Keep Changing Html After Save
TinyMce Keep Changing Html Before/After Save
avatar niosme niosme - edited - 28 Apr 2023
avatar brianteeman
brianteeman - comment - 28 Apr 2023

Tinymce is making these changes. Nothing joomla can do about that. You can verify it by checking on one of tinymce demos.

avatar niosme
niosme - comment - 28 Apr 2023

I figured that out.But is there any way to prevent all those changes from being doing and to be handled by joomla filters completly?
Cause its kinda annoying to go changing all the paths it thinks its right cause joomla can manipulate them fine.This is a trouble on site transfering.
The only solution is to change the editor to another?
I appreciate your time!

avatar niosme
niosme - comment - 28 Apr 2023

https://www.tiny.cloud/docs/configure/url-handling/#interactiveexamplenourlconversion

Here it doesnt convert the urls.Maybe its on the initiallization settings/configuration of the tinymce.

It would be perfect if we got some important controls like that in tinymce plugin settings so tinymce can be initiallized on the needings of everyone.

avatar brianteeman
brianteeman - comment - 4 May 2023

when i type "/index.php" it will always turn it to "myexample.com/index.php" by tinymce.
changes from the tinymce plugin paths from relevant to absolute but behaviour stays the same.

I can not confirm that. I only get that when the option is set to absolute (not the default behaviour). This option is using the tinymce setting as documented in the link you showed

avatar Hackwar Hackwar - change - 22 Aug 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Aug 2023
avatar Hackwar
Hackwar - comment - 22 Aug 2023

I set the bug label because I don't think it is a feature request. That does not mean, that I consider this a valid bug.

avatar niosme
niosme - comment - 22 Aug 2023

It looks like it already have been fixed.
It was a problem before but after updates it is fixed.

avatar Hackwar Hackwar - change - 22 Aug 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-08-22 09:03:36
Closed_By Hackwar
avatar Hackwar Hackwar - close - 22 Aug 2023

Add a Comment

Login with GitHub to post a comment