Aggregated javascript contains BOM's and thereby breaks JSMIN+

Kiphaas7 - August 2, 2009 - 23:15
Project:Javascript Aggregator
Version:6.x-1.3
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

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

Kiphaas7 - August 2, 2009 - 23:24

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

tetsuo2501 - August 19, 2009 - 20:08

Same here. I get Parse error: Illegal token in file '[inline]' on line 2132
Subscribe.

#3

Kiphaas7 - August 25, 2009 - 12:11

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

gausarts - September 6, 2009 - 12:12

Same error here:

Parse error: Syntax error in file '[inline]' on line 6648

Any solution yet?

#5

murokoma - September 11, 2009 - 15:57

Subscribing

#6

NigelCunningham - November 12, 2009 - 04:07

Subscribing

 
 

Drupal is a registered trademark of Dries Buytaert.