Bug 313498 - Javascript validator doesn't detect non-javascript scripts
Summary: Javascript validator doesn't detect non-javascript scripts
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: Web (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Koke Laast CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2010-05-19 06:01 EDT by Koke Laast CLA
Modified: 2010-06-28 14:28 EDT (History)
1 user (show)

See Also:
cmjaun: review+
thatnitind: review+


Attachments
This the unified diff of my file with the bug solved (1.34 KB, patch)
2010-05-21 03:09 EDT, Koke Laast CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Koke Laast CLA 2010-05-19 06:01:45 EDT
Build Identifier: 20100218-1602

The JavaScript validator tries to validates every script tag in a JSP file, no matter the 'type' or 'language' attributes value.

SOLUTION:
The problem is in file org.eclipse.wst.jsdt.web.core.javascript.JsTranslator, line 278, because if the 'type' or 'language' attributes are not javascript it applies the default JavaScript configuration for the file (by default true), no matter this attributes exist or not.
It is solved if you change this line for:
*******************************************************************************
						if (NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("type")) || NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("language")) || (nh.getAttributeValue("type")==null && nh.getAttributeValue("language")==null && isGlobalJs())) { //$NON-NLS-1$ //$NON-NLS-2$
*******************************************************************************
testing that the 'type' and 'language' attributes don't exist before applying the default script configuration.

I apologize if this is not the place to write the solution but I don't know where to do it. Thanx a lot.

Reproducible: Always

Steps to Reproduce:
1.Write a small script in a JSP file in vbscript with the right 'type' (text/vbscript) or 'language' (vbs or vbscript) attribute. Example:

<script language="vbs">
	function confirmation(msg)
		v=msgbox(msg, vbquestion+vbyesnocancel,"Attention")
		select case v
			case 6
				v="yes"
			case 7
				v="no"
			case 2
				v="cancel"
		end select
		confirmation=v
	end function
</script>

2.Run the JavaScript validator
3.The validator "detects" a lot of problems as it is not JavaScript code
Comment 1 Chris Jaun CLA 2010-05-20 10:21:31 EDT
Hi Koke,

What you should do is create a patch and attach it to this bug. Then one of the committers will review it.

Right-click on your project -> Team -> Create patch...
Comment 2 Koke Laast CLA 2010-05-21 03:09:42 EDT
Created attachment 169475 [details]
This the unified diff of my file with the bug solved

I hope I have generated it right. I am not used to this.
Comment 3 Chris Jaun CLA 2010-05-21 13:39:38 EDT
Thank you.

We will review the patch in the next week.

Chris
Comment 4 Chris Jaun CLA 2010-06-15 10:49:24 EDT
This is working for me.

Please have a look Nitin.
Comment 5 Chris Jaun CLA 2010-06-28 14:28:53 EDT
Patch checked in.