Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313498

Summary: Javascript validator doesn't detect non-javascript scripts
Product: [WebTools] JSDT Reporter: Koke Laast <jm.urio>
Component: WebAssignee: Koke Laast <jm.urio>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun
Version: unspecifiedKeywords: usability
Target Milestone: 3.2.1Flags: cmjaun: review+
thatnitind: review+
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
This the unified diff of my file with the bug solved none

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.