2009.03.23

I've been developing a site using Wildflower CMS developed using CakePHP and ran into an infuriating problem. After working on it for several weeks without issue I started receiving javascript errors that caused everything to come to a grinding halt. The errors were all reported using Firebug and the javascript debugger. The culprit:

Unterminated String Literal

After that in the Firebug console was:

$ is not defined

I knew there was a strong possibility that the first error was somehow causing the second and that top-down debugging was the way to go. After inspecting the javascript code I discovered that there was a variable assignment going on that spanned several lines. This might be legal in PHP but not javascript. For example:

NO GOOD.

So what was causing this? Why wasn't Wildflower's JLM packager stripping newlines out? After some digging I found the method that was supposed to be doing just that and noticed it was only removing new lines, not carriage returns.

The Fix

/wildflower/controllers/components/jlm_packager.php

As you can tell, I just added carriage returns to the list of characters to be removed or altered (in this case removed). Initially this was never a problem. Only after I copied files down from a unix server to my windows machine did this start to occur. Hopefully this saves someone else some time.

Get my RSS Feed!

Comments

klevo on (3.24.2009 8:36 am) says

Thanks man, I'll commit the fix ASAP. When you find something like this it's good to drop a note on the forums: http://forums.wf.klevo.sk/

 

klevo on (3.24.2009 8:41 am) says

You're using the 1.2 beta right? This this is OK in 1.3 on Github.

 

Mike Bernat on (3.30.2009 12:17 am) says

@klevo

Awesome! That's great to hear. I realized I didn't expressly state my appreciation for the work you've put into Wildflower. I've been looking for an excuse to put it to use and finally got that chance and so far I've been loving it. Keep up the good work.

 

Etienne on (6.19.2009 7:31 am) says

Hi,

Thanks for this post. It helped me a great deal. This wa probably one of the most mind boggling errors I've gotten in a long time but this helped immediately.

Thanks a lot for the effort you put in.

Regards

 
* Name
* Email (Will not be displayed)
Website