Hello!
After about 6 months running moodle without the HTML editor, today I finally used the mozilla javascript console to find out where was the bug.
I just discovered my hosting provider was injecting HTML advertisement code right into the javascript code in /lib/editor/htmlarea/htmlarea.php
The solution is easy: making some replacements in code in order to avoid "</head>" and "<body>" appear in javascript code.
1- Replace:
HTMLArea.RE_head = /<head>((.|\n)*?)<\/head>/i;
HTMLArea.RE_body = /<body>((.|\n)*?)<\/body>/i;
With:
HTMLArea.RE_head = /<h[e]ad>((.|\n)*?)<\/h[e]ad>/i;
HTMLArea.RE_body = /<b[o]dy>((.|\n)*?)<\/b[o]dy>/i;
2- Replace:
html += "</head>\n";
html += '</body>\n';
with:
html += "</he"+"ad>\n";
html += '</bo'+'dy>\n';
3- Replace:
html += "</head>";
with:
html +="</he"+"ad>";
This procedure specially applies for those using the same hosting provider I use, byethost. I will post this same solution into byethost help forums.