slimit icon indicating copy to clipboard operation
slimit copied to clipboard

SlimIt breaks on unicode byteorder marks

Open pannal opened this issue 12 years ago • 6 comments

Example: "jquery.blockUI.js" and "jquery.caret.min.js"

Both have the unicode byteorder mark "EF BB BF" before or after the first line of code. Result is:

Illegal character '\xbb' at 1:1 after LexToken(ID,'\xef',1,0) Illegal character '\xbf' at 1:2 after LexToken(ID,'\xef',1,0)

and errors in the browser with compressed versions of those: ERROR: ILLEGAL TOKEN

pannal avatar Sep 03 '12 03:09 pannal

Hi,

Could you give me links to those particular files with BOMs?

rspivak avatar Sep 03 '12 15:09 rspivak

http://malsup.github.com/jquery.blockUI.js and http://jcaret.googlecode.com/files/jquery.caret.1.02.min.js

pannal avatar Sep 03 '12 20:09 pannal

Well, essentially this isn't slimit's fault, though it shouldn't break as BOMs are valid (at least in the correct position) I guess.

pannal avatar Sep 07 '12 23:09 pannal

I agree. It's not the slimit's fault per se, but I don't mind adding BOM cleanup to Slimit. And thanks for the above links.

rspivak avatar Sep 08 '12 18:09 rspivak

Illegal character '\xbb' at 1:10 after LexToken(ID,'\xef',1,9) Illegal character '\xbf' at 1:11 after LexToken(ID,'\xef',1,9)

аналогичная ошибка произошла при использовании в теле шаблона :

{% compress js %} {% endcompress %}

дело в том, что я скопировал script с web-страницы, где закрался спец-символ &#65279 Естественно в шаблоне его совсем не видно, поэтому я указал вместо него [invisible symbol BOM] И такое видимо, случается, даже почитав этот топик не сразу понял где ошибка, помогло только попеременное включение скриптов.

git вдобавок порезал мой пост...

crazyzubr avatar Sep 16 '12 15:09 crazyzubr

Еще один момент:

Unexpected token (DIV, '/') at 1:231862 between LexToken(COLON,':',1,231860) and LexToken(BXOR,'^',1,231863)

"regex":"/^[0-9-()\ ]+$/" // <<-- ERROR

решение:

"regex":"/^[0-9-()\u0020]+$/" // <<-- RESOLVE

crazyzubr avatar Sep 16 '12 16:09 crazyzubr