New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assume script tags are always JS #88

Open
alexchandel opened this Issue Oct 14, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@alexchandel

alexchandel commented Oct 14, 2015

Yes, it's horrible, but there are things (like Honeywell's Experion HMI WebBuilder) that produce and interpret HTML with <script language=VBScript>, and non-JS script tags cause this package to utterly fail to parse the rest of the file. Here's a truncated sample of what that would look like (note ellipses):

...
<META name=GENERATOR content="MSHTML 8.00.7601.18715"><LINK id=HDXStylesheet 
rel=stylesheet type=text/css href="..\foocss\sp.css">
<SCRIPT language=VBScript for="" type="" defer event="">'--------------------------------------
'Scada RegCntl - Mode; Hialm Type; EUDesc; 
'--------------------------------------
sub Scd_RegCntl_Mode_Hialm_EUDesc_OnUpdate(oSource,iLen)
    dim sMode,sNMode,iHialmT, iAlmEnbState,oShape,oAlm
    ...
end sub</SCRIPT>

<BODY 
style="BACKGROUND-COLOR: transparent; MARGIN: 0px; ZOOM: 1; FONT-SIZE: 12pt; OVERFLOW: auto">
...

Even GitHub's markdown preview hates this, but supporting it would make Atom applicable to other industries and to engineers who have to slog through such code-salads.

@50Wliu

This comment has been minimized.

Member

50Wliu commented Nov 12, 2015

So are you suggesting that we also look for a language attribute while parsing script tags (instead of just type)?

@alexchandel

This comment has been minimized.

alexchandel commented Dec 17, 2015

@50Wliu Ah. It's non-standard. It would definitely help though...

@alexchandel

This comment has been minimized.

alexchandel commented Jan 10, 2018

Apparently the language attribute was deprecated a while ago, but still functions. VBScript scripts are still supported on Windows in IE 11. So it would be nice if we looked at the language attribute if type is missing.

@alexchandel

This comment has been minimized.

alexchandel commented Jan 10, 2018

Actually, even with a type attribute, as in type="text/vbscript" below, language-html doesn't handle the script tag well, highlighting most of it red due to VBScript's use of lone single quotes to mark one-line comments:

...
<META name=GENERATOR content="MSHTML 8.00.7601.18715"><LINK id=HDXStylesheet 
rel=stylesheet type=text/css href="..\foocss\sp.css">
<SCRIPT type="text/vbscript">'--------------------------------------
'Scada RegCntl - Mode; Hialm Type; EUDesc; 
'--------------------------------------
sub Scd_RegCntl_Mode_Hialm_EUDesc_OnUpdate(oSource,iLen)
    dim sMode,sNMode,iHialmT, iAlmEnbState,oShape,oAlm
    ...
end sub</SCRIPT>

<BODY 
style="BACKGROUND-COLOR: transparent; MARGIN: 0px; ZOOM: 1; FONT-SIZE: 12pt; OVERFLOW: auto">
...
@50Wliu

This comment has been minimized.

Member

50Wliu commented Jan 10, 2018

type is easier to handle. We'd just need to add a rule for it.

@haukex

This comment has been minimized.

haukex commented Oct 19, 2018

I second this issue... HTML 5 says that omitting the type attribute, setting it to the empty string, or setting it to a JavaScript MIME type, means it's JavaScript. Other than the special case of module, any other value of type, as long as it's a valid MIME type string, "means that the script is a data block, which is not processed." So for unknown MIME types, it'd be nice if syntax highlighting was disabled in such <script type="..."> blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment