<s> import re <EOL> class URLMonitor : <EOL> '''<STR_LIT>''' <EOL> javascriptTrickery = [ re . compile ( "<STR_LIT>" ) ] <EOL> _instance = None <EOL> def __init__ ( self ) : <EOL> self . strippedURLs = set ( ) <EOL> self . strippedURLPorts = { } <EOL> self . faviconReplacement = False <EOL> def isSecureLink ( self , client , url ) : <EOL> for expression in URLMonitor . javascriptTrickery : <EOL> if ( re . match ( expression , url ) ) : <EOL> return True <EOL> return ( client , url ) in self . strippedURLs <EOL> def getSecurePort ( self , client , url ) : <EOL> if ( client , url ) in self . strippedURLs : <EOL> return self . strippedURLPorts [ ( client , url ) ] <EOL> else : <EOL> return <NUM_LIT> <EOL> def addSecureLink ( self , client , url ) : <EOL> methodIndex = url . find ( "<STR_LIT>" ) + <NUM_LIT:2> <EOL> method = url [ <NUM_LIT:0> : methodIndex ] <EOL> pathIndex = url . find ( "<STR_LIT:/>" , methodIndex ) <EOL> host = url [ methodIndex : pathIndex ] <EOL> path = url [ pathIndex : ] <EOL> port = <NUM_LIT> <EOL> portIndex = host . find ( "<STR_LIT::>" ) <EOL> if ( portIndex != - <NUM_LIT:1> ) : <EOL> host = host [ <NUM_LIT:0> : portIndex ] <EOL> port = host [ portIndex + <NUM_LIT:1> : ] <EOL> if len ( port ) == <NUM_LIT:0> : <EOL> port = <NUM_LIT> <EOL> url = method + host + path <EOL> self . strippedURLs . add ( ( client , url ) ) <EOL> self . strippedURLPorts [ ( client , url ) ] = int ( port ) <EOL> def setFaviconSpoofing ( self , faviconSpoofing ) : <EOL> self . faviconSpoofing = faviconSpoofing <EOL> def isFaviconSpoofing ( self ) : <EOL> return self . faviconSpoofing <EOL> def isSecureFavicon ( self , client , url ) : <EOL> return ( ( self . faviconSpoofing == True ) and ( url . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) ) <EOL> def getInstance ( ) : <EOL> if URLMonitor . _instance == None : <EOL> URLMonitor . _instance = URLMonitor ( ) <EOL> return URLMonitor . _instance <EOL> getInstance = staticmethod ( getInstance ) </s>
