Author Topic: Javascript rcmail is undefined  (Read 7678 times)

Offline dev20

  • Newbie
  • *
  • Posts: 5
Javascript rcmail is undefined
« on: March 16, 2007, 08:37:44 PM »
Hi, I have webmail installed with postfix and everything is fine and dandy except for two things. One is that signatures do not work. If its HTML it puts "undefined" in the body, and if its not HTML it puts nothing. Also, my main concern, is that there is a javascript error on the compose page. Firefox reports that the error is rcmail is undefined, line 1, obviously wrong. I put alerts throughout the page and all I got out of it was that the page loads fine, its an event maybe onload or something that triggers it. It happens in IE7 and FF, but apparently not IE6. This also only happens with the HTML toolbar is turned on, for composing HTML emails. Got any ideas?

P.S. I dont know if this was custom added for my company, but there is a regex that replaces onevents from HTML body tags. The regex is completely wrong and breaks emails very badly that have the word "on" in them. It replaces everything from the word on till a = mark. I fixed it, just adding a P.S.

Offline bugler

  • Jr. Member
  • **
  • Posts: 54
Re: Javascript rcmail is undefined
« Reply #1 on: March 17, 2007, 06:30:50 AM »
If you get a javascript error you can install firefox and then go to the page giving errors and open the error console in firefox (tools->error console) and you will see which javascript line is causing the error).

Report the error and maybe we can help.

IE also give some information on javascript errors but it is usually rubbish (for a change).

Offline dev20

  • Newbie
  • *
  • Posts: 5
Re: Javascript rcmail is undefined
« Reply #2 on: March 20, 2007, 03:02:55 PM »
Yeah.... I'm sorry to say but you apparently didn't read my post? I stated that firefox reported an error on line 1, that rcmail is undefined. I found the problem.

I don't know how roundcube is developed with webmail or whats going on.. but there is many many problems with it that I had to manually fix just to get the barebones working.

First off in the app.js file, it accesses the signatures[index]['text'] and ['is_html']

Well text and is_html are no where, not even close, or attempted, to be set. is_html is never populated, and you simply remove ['text'] from all its occurances to fix signatures.

Another problem is signatures stop working, along with the page bugs out like crazy, if you do not have browser caching. Since the javascript file is 100k+, it takes forever to load. And since you do not wait for body onload to fire to start init, init fires before the JS file is downloaded and you get RCMAIL IS UNDEFINED. Yes I found my own problem.

So my solution was too replace the following code, with the code following it:

 // don't wait for page onload. Call init at the bottom of the page (delayed)
 $javascript_foot = "if (window.call_init)\ncall_init('$JS_OBJECT_NAME');";


 // don't wait for page onload. Call init at the bottom of the page (delayed)
 $javascript_foot = "
   function onload_call_init(event) {
      if (window.call_init)
         call_init('$JS_OBJECT_NAME');
   }
   window.onload=onload_call_init;";



Another error is plain text emails. Where the software automatically puts A links into plain text emails for you, but then it does a

Yeah well what about line breaks?

$body = preg_replace("/\n/", "
", $body);

That line of code needs to be added above
return "
".$body."\n
";
this is in func.inc



Another error, which is infact, HORRIBLE. Is the "protection" of emails from malicious javascript. You know like onclick= in an email.

Well the regex that is used to replace it, replaced HALF the email if it has the word ON in it. So lets say a person sends..

Lets walk the dog on saturday, what do YOU think?

Well the program would allow you to read..
_removed="text-decoration:underline">YOU think?


The fix is simple.
You replace it with this regex, which is infact, correct.
 $body = preg_replace('/(<\w+\s[^><]*)(on[^<>=]+)=/im', '\1\2__removed=', $body);
The original is really silly and makes no sense. do a search for _removed and you will find it.


Please do not get me wrong, I'm not trying to be hostile, I'm just frustrated cause I do not work in this department specifically but I had to assist anyway and there were just so many problems.. I understand you are beta, but please put more effort into these things, its what matters.

P.S. Again I have no idea what the association with this code is with the company I'm posting at.. I'm just a programmer who got assigned to the project.