Package com.isomorphic.js
Class JSSyntaxScannerFilter
java.lang.Object
com.isomorphic.servlet.BaseFilter
com.isomorphic.js.JSSyntaxScannerFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
public class JSSyntaxScannerFilter extends com.isomorphic.servlet.BaseFilter
JSSyntaxScannerFilter
looks for Javascript syntax errors in code sent to the browser. The purpose of this filter is to catch syntax errors that are poorly reported on by the browsers - such as, for example, the trailing comma bug. It's safe to register this filter in front of arbitrary files/servlets/filters. If the mime type is other than one of those specified by the scannableMimeTypes configuration parameter (see below), the stream is passed through without inspection. Further, if the mime type is deriveable from the extension then bufferring is avoided for non-scannable mime types.
The filter scans javascript files in their entirety. For html files, the filter looks for javascript code in <SCRIPT> tag and scans that code for any errors.
All errors are reported in the ISC server logs, complete with a source line number for the error.
Errors detected
- Trailing comma at the end of object literals and arrays.
Note that if the upstream content is served compressed it will be ignored by the scanner. Typical cases include: FileAssembler virtual urls with compress=true directives, compressed FileDownload content, or CompressionFilter if registered upstream from this filter.
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
If you're using the Assembly module, this parameter controls whether or not assembled files are scanned by this filter.Comma or separated list of scannable mimeTypes.boolean
If set to true, then any syntax errors reported by this filter are sent to the browser in lieu of the content containing the errors, the errors are also still logged in the server logs.
-
Field Details
-
scanAssembledFiles
public boolean scanAssembledFilesIf you're using the Assembly module, this parameter controls whether or not assembled files are scanned by this filter. Since the Assembler itself scans the component files, a scan of the resulting file is somewhat reduntant, but can sometimes expose bugs in code that spans multiples files.This parameter defaults to false.
-
scannableMimeTypes
Comma or separated list of scannable mimeTypes. By default this list includes: text/html, application/x-javascript, text/javascript, text/ecmascript, application/javascript. -
sendErrorsToBrowser
public boolean sendErrorsToBrowserIf set to true, then any syntax errors reported by this filter are sent to the browser in lieu of the content containing the errors, the errors are also still logged in the server logs. If set to false, the errors are reflected only in the server logs and the content containing the errors is sent to the browser as it would be if this filter had not intercepted the request.This parameter defaults to true.
-