Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions JSAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,13 @@ def isJavascript(content):
@param content: A string
@return: A boolean, True if it seems to contain Javascript code or False in the other case
'''
jsStrings = ['var ', ';', ')', '(', 'function ', '=', '{', '}', 'if ', 'else', 'return', 'while ', 'for ',
jsStrings = ['var ', ';', ')', '(', 'function ', '=', '{', '}', 'if(', 'if (', 'else{', 'else {','else if', 'return', 'while(', 'while (', 'for(', 'for (',
',', 'eval']
keyStrings = [';', '(', ')']
reVarInit = 'var [\w0-9]+\s*?='
reFunctionCall = '[\w0-9]+\s*?\(.*?\)\s*?;'
stringsFound = []
limit = 15
minDistinctStringsFound = 4
#JS should at least contain ';', ')', '(', 'var', '='
minDistinctStringsFound = 5
minRatio = 10
results = 0
length = len(content)
Expand Down Expand Up @@ -279,4 +278,4 @@ def unescape(escapedBytes, unicode = True):
unescapedBytes = escapedBytes
except:
return (-1, 'Error while unescaping the bytes')
return (0, unescapedBytes)
return (0, unescapedBytes)