Aggregated javascript contains BOM's and thereby breaks JSMIN+
| Project: | Javascript Aggregator |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Kinda cryptic title, but I wanted to cram as much info in there as possible. Basically the following happened. Installed the new 1.3 version that includes JSMIN+, and since I'm a regular on tweakers.net where the author of JSMIN+ resides, I decided to give it spin. Long story short, it doesn't work. It threw an error like this:
Parse error: Illegal token in file '[inline]' on line 4377
The corresponding line is:
;// $Id: drupal.js,v 1.41.2.3 2008/06/25 09:06:57 goba Exp $
At first, since JSMIN worked fine, and JSMIN+ didn't, I assumed it was a bug within JSMIN+. After contacting the author (the comments are in dutch, sorry), he told me that the "funny character" you see in the codeline, is actually a non-stripped BOM (Byte Order Mark), which is caused by aggregation.
He also said that even without minification, BOM's should throw js errors, but because JSMIN really parses and validates the code, it get's stripped. JSMIN+ does not do real parsing and validating, so it stays in and throws an error.
So, BOM's should be stripped, but I'm not sure if this is an issue with this module, or drupal core (since aggregation is part of core, but I'm not sure if the module does aggregation on it's own).

#1
In the comment above, the BOM is stripped away. Clicking on the link to the author of JSMIN+ leads you to the exact same example on the authors page where the BOM isn't stripped, but changed into entity, so it is really there, just not in the comment above :).
#2
Same here. I get Parse error: Illegal token in file '[inline]' on line 2132
Subscribe.
#3
Tetsuo: since the error is kinda vague (illegal token could be anything), are you sure it's also a BOM?
EDIT: a solution would be according to http://www.xs4all.nl/~mechiel/projects/bomstrip/
<?php$fp = fopen('php://stdin','r');
$str = fread($fp, 3);
if ($str != "\xef\xbb\xbf")
printf("%s",$str);
fpassthru($fp);
fclose($fp);
?>
#4
Same error here:
Parse error: Syntax error in file '[inline]' on line 6648Any solution yet?
#5
Subscribing
#6
Subscribing