Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Don't assume script tags are always JS #88

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

Don't assume script tags are always JS #88

alexchandel opened this issue Oct 14, 2015 · 6 comments
Labels

Comments

@alexchandel
Copy link

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.

@winstliu
Copy link
Contributor

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

@alexchandel
Copy link
Author

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

@alexchandel
Copy link
Author

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
Copy link
Author

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">
...

@winstliu
Copy link
Contributor

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

@haukex
Copy link

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants