SOLVED [CPANEL-30263] HTML changes after saving and adds charset automatically

TristanAgilisIT

Registered
Dec 17, 2019
1
2
3
Australia
cPanel Access Level
Root Administrator
Hi cPanel Support,

I would like to add to this issue as it can be pretty nasty and I am not sure the examples in this thread convey the full potential negative impact of this feature/bug.

This replacement of meta tags seems to take place in PHP files as well as HTML files and this is one place where things can get particularly messy. Consider the following real-world example:
PHP:
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
In the cPanel file editor it is automatically replaced with this:
PHP:
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    " />
You may have noticed that the substituted PHP code will now generate invalid HTML resulting in the WordPress charset not being inserted and the original self-closing portion of the tag being left as detritus in the file. The leftover remnants of the self-closing meta tag are interpreted by some browsers (such as Chrome) as text to be printed and they also trigger the immediate closure of the head tag at that point in the file. Now, it is true that self-closing is not required for void element tags and ideally would not be used but to the best of my knowledge it is permissible under the HTML5 standards and is used by many developers in a wide range of free and commercial products. Editing any of these files containing a meta tag in the cPanel editor will cause them to generate invalid HTML. It is worth noting that this also affects PHP files that generate XHTML where the self-closing of void element tags such as the meta tag IS required by the standard.

I would also like to note that this code modification by the editor takes place at the time of opening so you never even see the actual file contents in the editor and there is no indication to the user that the file has been changed upon opening. The changes are of course not written to disk until the file is saved in the editor but the in-memory editor version of the file is modified at the time of opening.

Now I am not trying to cast aspersions; cPanel is an amazing product and cPanel support is exemplary. However, to give my two-cents on this issue: I would much rather not have an inbuilt editor at all than have one that changes the contents of a file I am editing, especially when it does so without notifying me and doubly so when it introduces serious bugs into portions of code that I didn't even touch. I am not sure why these modifications take place and I am sure there is a good reason but as an outsider, it seems like a bad idea for an editor to make silent changes to file contents under any circumstances.

To be thorough in my testing, I tried switching to the legacy editor by pressing the "Use legacy editor" button and then hitting the "Re-open" button to be sure, but this resulted in the same substitution behaviour as the new editor.

Cheers, and keep up the good work.
 
Last edited:

dxruss

Registered
Jan 16, 2020
2
2
3
England
cPanel Access Level
Website Owner
I'd just like to add this doesn't seem to be specifically targeting the <head> tag.

I'm experiencing this issue and on a Drupal install it is affecting an included section template:

<header<?php print $attributes; ?>>

is resulting in

<header<?php print $attributes; ?><meta http-equiv="Content-Type" content="text/html; charset=utf-8">>

So it appears it is looking for the first instance of a tag including the string "head", then adding it in after the first following > it finds?
 
  • Like
Reactions: Rajeeva Lochana

A Hartonian

Active Member
May 22, 2018
44
9
8
Oman
cPanel Access Level
DataCenter Provider
Hello,

We have the same problem on two servers.
Its a bit odd as we have 23 baremetal and more than 400 VPSs. While all settings and cPanel versions are the same, there are only 2 servers (1 Baremetal and 1 KVM based VPS) having this issue.

Looking forward to the fix.

Thank you
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
@cPanelLauren When is this issue going to be fixed, any soon?
I don't have a timeframe on this. The best I can do is tell you that the case is active and open right now. As soon as I have more information, I'll update the thread here.
 
  • Like
Reactions: Rajeeva Lochana

Rajeeva Lochana

Well-Known Member
Community Guide Contributor
May 27, 2019
122
38
28
India
cPanel Access Level
Root Administrator
I wish I could go back 13 years and plant potatoes in my farm instead of getting into hosting business.
I am not so sure if you are trying to be funny or rude, but anyways, hahaha. Sorry if I hurt your feelings in some way :( Please let me know. Also, @cPanelLauren, delete my previous post.
 
Last edited:
  • Like
Reactions: A Hartonian

dxruss

Registered
Jan 16, 2020
2
2
3
England
cPanel Access Level
Website Owner
The only temporary workaround I have at the moment is to download the file, edit locally, and reupload to overwrite, rather than editing directly via cPanel.

Quite an obvious solution to most I'm sure, but currently having to use this method on a few templates and should do the trick for anyone who has templated with persisting greater than symbols appearing at the top of their page.
 
  • Like
Reactions: Rajeeva Lochana

A Hartonian

Active Member
May 22, 2018
44
9
8
Oman
cPanel Access Level
DataCenter Provider
The only temporary workaround I have at the moment is to download the file, edit locally, and reupload to overwrite, rather than editing directly via cPanel.

Quite an obvious solution to most I'm sure, but currently having to use this method on a few templates and should do the trick for anyone who has templated with persisting greater than symbols appearing at the top of their page.
You see, the problem is that there are hundreds of files we did not even open it in the first place. They automatically got the meta tag. Our main website has +800 files. Plus our customers have the same problem on the shared servers. This is certainly not a workaround, this would work for a website with a few pages. On top of that w3 shows tons of error in many pages, google webmaster is shooting tons of error for that.

This is issue is a quick pool from technical point of view and it shouldn't take this long to get fixed. 12 of october 2019 this was reported by @rajeevacj today is almost february 2020.
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
This is issue is a quick pool from technical point of view and it shouldn't take this long to get fixed. 12 of october 2019 this was reported by @rajeevacj today is almost february 2020.
Some insight into that, while, yes on the surface this would appear to be something that would be fixed quickly, it's not always that simple. There are things that have to be weighed when determining to make a change in a feature - longevity/direction (is this feature going to be present in future versions), If 3rd party is it modifiable?, Impact (what impact does this have on the product), Unintended consequences (will changes made here affect other items), Backlog (does the team have time for this in this sprint or are other features/changes taking precedence), etc.. I'm not saying specifically which if any of these are the case in this issue but really, it's not just issue reported -> Issue Fixed/Won't Fix.

Now, I do have an update on this, as of today the issue is in progress which indicates that it's being actively worked. From the case notes there is a fix for this which was committed today. I'll update you as to the status as it becomes available. Right now it looks like the fix will be available in v86.
 

Rajeeva Lochana

Well-Known Member
Community Guide Contributor
May 27, 2019
122
38
28
India
cPanel Access Level
Root Administrator
Now, I do have an update on this, as of today the issue is in progress which indicates that it's being actively worked. From the case notes there is a fix for this which was committed today. I'll update you as to the status as it becomes available. Right now it looks like the fix will be available in v86.
Yay, glad that this is going to be fixed soon.
 
  • Like
Reactions: cPanelLauren