bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" # first: weed out the rules that dont apply to this url rules = filter(lambda r, u=url: r.appliesTo(u), self.rules) rewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url):...
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" # first: weed out the rules that dont apply to this urlrewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url): continue if rule.get_name()=='rewrite': rewrites.append(rule...
16,000
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = attrs[name] if not val: return self.jsEnv.attachListener(self) self.jsEnv.executeScriptAsFunction(val, 0.0) self.jsEnv.detachListener(self) res = self.popup_counter self.popup_counter = 0 return res
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = resolve_html_entities(attrs[name]) if not val: return self.jsEnv.attachListener(self) self.jsEnv.executeScriptAsFunction(val, 0.0) self.jsEnv.detachListener(self) res = self.popup_counter self.popup_counter = 0 return res
16,001
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = attrs[name] if not val: return self.jsEnv.attachListener(self) self.jsEnv.executeScriptAsFunction(val, 0.0) self.jsEnv.detachListener(self) res = self.popup_counter self.popup_counter = 0 return res
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = attrs[name] if not val: return self.jsEnv.attachListener(self) try: self.jsEnv.executeScriptAsFunction(val, 0.0) except jslib.error, msg: pass self.jsEnv.detachListener(self) res = self.popup_counter self.popup_counter = 0...
16,002
def get_date_rfc1123 (timesecs): """ RFC 822, updated by RFC 1123 Grammar: rfc1123-date = wkday "," SP date1 SP time SP "GMT" date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fr...
def get_date_rfc1123 (timesecs): """ RFC 822, updated by RFC 1123 Grammar: rfc1123-date = wkday "," SP date1 SP time SP "GMT" date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fr...
16,003
def get_date_rfc850 (timesecs): """ RFC 850, obsoleted by RFC 1036 Grammar: rfc850-date = weekday "," SP date2 SP time SP "GMT" date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 weekday = "Monday" | "Tuesday" | "Wednesda...
def get_date_rfc850 (timesecs): """ RFC 850, obsoleted by RFC 1036 Grammar: rfc850-date = weekday "," SP date2 SP time SP "GMT" date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 weekday = "Monday" | "Tuesday" | "Wednesda...
16,004
def init (confdir=wc.ConfigDir): global config config = Configuration(confdir) import wc.filter.rating wc.filter.rating.rating_cache_load() return config
def init (confdir=wc.ConfigDir): global config config = Configuration(confdir) return config
16,005
def start_element (self, name, attrs): """handle start tag of folder, rule or nested element""" super(ZapperParser, self).start_element(name, attrs) self.cmode = name if name in rulenames: self.rule = wc.filter.GetRuleFromName(name) self.rule.fill_attrs(attrs, name) self.folder.append_rule(self.rule) # tag has characte...
def start_element (self, name, attrs): """handle start tag of folder, rule or nested element""" super(ZapperParser, self).start_element(name, attrs) self.cmode = name if name in rulenames: self.rule = wc.filter.GetRuleFromName(name) self.rule.fill_attrs(attrs, name) self.folder.append_rule(self.rule) # tag has characte...
16,006
def end_element (self, name): """handle end tag of folder, rule or nested element""" self.cmode = None if self.rule is None: self.folder.end_data(name) else: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name == 'folder': if self.compile_data: self.folder.compile_dat...
def end_element (self, name): """handle end tag of folder, rule or nested element""" if self.error: if name == self.error: self.error = None else: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name == 'folder': if self.compile_data: self.folder.compile_data()
16,007
def end_element (self, name): """handle end tag of folder, rule or nested element""" self.cmode = None if self.rule is None: self.folder.end_data(name) else: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name == 'folder': if self.compile_data: self.folder.compile_dat...
def end_element (self, name): """handle end tag of folder, rule or nested element""" self.cmode = None if self.rule is None: self.folder.end_data(name) else: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name == 'folder': if self.compile_data: self.folder.compile_dat...
16,008
def character_data (self, data): """handle rule of folder character data""" if self.cmode: if self.rule is None: self.folder.fill_data(data, self.cmode) else: self.rule.fill_data(data, self.cmode)
def character_data (self, data): """handle rule of folder character data""" if self.error: pass elif self.cmode: if self.rule is None: self.folder.fill_data(data, self.cmode) else: self.rule.fill_data(data, self.cmode)
16,009
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
def filter_tag (self, tag, attrs): if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, attrs] if self.part==TAG: return [DATA, self.replacement] if self.part==ENCLOSED: return [STARTTAG, tag, attrs] newattrs = {} # look for matching tag attributes for attr,val in attr...
16,010
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
16,011
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
16,012
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
def filter_tag (self, tag, attrs): debug(FILTER, "rule %s filter_tag", self.title) debug(FILTER, "original tag %s attrs %s", `tag`, attrs) debug(FILTER, "replace %s with %s", num_part(self.part), `self.replacement`) if self.part==COMPLETE: return [DATA, ""] if self.part==TAGNAME: return [STARTTAG, self.replacement, att...
16,013
def jsStartElement (self, tag, attrs): """Check popups for onmouseout and onmouseover. Inline extern javascript sources (only in the same domain)""" changed = 0 for name in ('onmouseover', 'onmouseout'): if attrs.has_key(name) and self.jsPopup(attrs, name): del attrs[name] changed = 1 if tag=='form': name = attrs.get('...
def jsStartElement (self, tag, attrs): """Check popups for onmouseout and onmouseover. Inline extern javascript sources (only in the same domain)""" changed = 0 for name in ('onmouseover', 'onmouseout'): if attrs.has_key(name) and self.jsPopup(attrs, name): del attrs[name] changed = 1 if tag=='form': name = attrs.get('...
16,014
def jsScriptSrc (self, url, language): if not url: return #debug(HURT_ME_PLENTY, "jsScriptSrc", url, language) try: script = urlutils.open_url(url) except: print >>sys.stderr, "exception fetching script url", `url` return if not script: return ver = 0.0 if language: mo = re.search(r'(?i)javascript(?P<num>\d\.\d)', lang...
def jsScriptSrc (self, url, language): if not url: return #debug(HURT_ME_PLENTY, "jsScriptSrc", url, language) try: script = urlutils.open_url(url) except: print >>sys.stderr, "exception fetching script url", `url` return if not script: return ver = 0.0 if language: mo = re.search(r'(?i)javascript(?P<num>\d\.\d)', lang...
16,015
def jsEndElement (self, tag): """parse generated html for scripts""" if not self.buffer: print >>sys.stderr, "empty buffer on </script>" return if self.buffer[-1][0]!=DATA: print >>sys.stderr, "missing data for </script>", self.buffer[-1:] return script = self.buffer[-1][1].strip() del self.buffer[-1] if not (self.buff...
def jsEndElement (self, tag): """parse generated html for scripts""" if not self.buffer: print >>sys.stderr, "empty buffer on </script>" return if self.buffer[-1][0]!=DATA: print >>sys.stderr, "missing data for </script>", self.buffer[-1:] return script = self.buffer[-1][1].strip() del self.buffer[-1] if not (self.buff...
16,016
def jsEndElement (self, tag): """parse generated html for scripts""" if not self.buffer: print >>sys.stderr, "empty buffer on </script>" return if self.buffer[-1][0]!=DATA: print >>sys.stderr, "missing data for </script>", self.buffer[-1:] return script = self.buffer[-1][1].strip() del self.buffer[-1] if not (self.buff...
def jsEndElement (self, tag): """parse generated html for scripts""" if not self.buffer: print >>sys.stderr, "empty buffer on </script>" return if self.buffer[-1][0]!=DATA: print >>sys.stderr, "missing data for </script>", self.buffer[-1:] return script = self.buffer[-1][1].strip() del self.buffer[-1] if not (self.buff...
16,017
def __init__ (self, ipaddr, port, client): """initialize connection object and connect to remove server""" super(wc.proxy.HttpServer.HttpServer, self).__init__(client, 'connect') # default values self.addr = (ipaddr, port) self.reset() # attempt connect self.create_socket(socket.AF_INET, socket.SOCK_STREAM, sslctx=wc.p...
def __init__ (self, ipaddr, port, client): """initialize connection object and connect to remove server""" super(wc.proxy.HttpServer.HttpServer, self).__init__(client, 'connect') # default values self.addr = (ipaddr, port) self.reset() # attempt connect self.create_socket(socket.AF_INET, socket.SOCK_STREAM, sslctx=wc.p...
16,018
def __repr__ (self): """object description""" if self.addr[1] != 80: portstr = ':%d' % self.addr[1] else: portstr = '' extra = '%s%s' % (self.addr[0], portstr) if self.socket: extra += " (%s)" % self.socket.state_string() if not self.connected: extra += " (unconnected)" #if len(extra) > 46: extra = extra[:43] + '...' r...
def __repr__ (self): """object description""" extra = "" if hasattr(self, "persistent") and self.persistent: extra += "persistent " if hasattr(self, "addr") and self.addr and self.addr[1] != 80: portstr = ':%d' % self.addr[1] else: portstr = '' extra = '%s%s' % (self.addr[0], portstr) if self.socket: extra += " (%s)" %...
16,019
def __repr__ (self): """object description""" if self.addr[1] != 80: portstr = ':%d' % self.addr[1] else: portstr = '' extra = '%s%s' % (self.addr[0], portstr) if self.socket: extra += " (%s)" % self.socket.state_string() if not self.connected: extra += " (unconnected)" #if len(extra) > 46: extra = extra[:43] + '...' r...
def __repr__ (self): """object description""" if self.addr[1] != 80: portstr = ':%d' % self.addr[1] extra += '%s%s' % (self.addr[0], portstr) if self.socket: extra += " (%s)" % self.socket.state_string() if not self.connected: extra += " (unconnected)" #if len(extra) > 46: extra = extra[:43] + '...' return '<%s:%-8s %s...
16,020
def exception (logname, msg, *args, **kwargs): """ Log an exception. return: None """ log = logging.getLogger(logname) if log.isEnabledFor(logging.EXCEPTION): _log(log.exception, msg, args, tb=kwargs.get("tb"))
def exception (logname, msg, *args, **kwargs): """ Log an exception. return: None """ log = logging.getLogger(logname) if log.isEnabledFor(logging.ERROR): _log(log.exception, msg, args, tb=kwargs.get("tb"))
16,021
def setUp (self): self.basedir = os.path.join(os.getcwd(), "wc", "magic", "tests", "data")
def setUp (self): self.basedir = os.path.join(os.getcwd(), "wc", "magic", "tests", "data")
16,022
def _form_apply_replace (form): # note: do not strip() the search and replace form values search = _getval(form, 'rule_search') if not search: error['rulesearch'] = True return if search!=currule.search: currule.search = search _compileRegex(currule, "search") info['rulesearch'] = True replace = _getval(form, 'rule_rep...
def _form_apply_replace (form): # note: do not strip() the search and replace form values search = _getval(form, 'rule_search') if not search: error['rulesearch'] = True return if search!=currule.search: currule.search = search _compileRegex(currule, "search") info['rulesearch'] = True replacement = _getval(form, 'rule...
16,023
def handle_dns (self, hostname, answer): assert self.state == 'dns' debug(PROXY, "%s handle dns", self) if not self.client.connected: warn(PROXY, "%s client closed after DNS", self) # The browser has already closed this connection, so abort return if answer.isFound(): self.ipaddr = answer.data[0] self.state = 'server' ...
def handle_dns (self, hostname, answer): assert self.state == 'dns' debug(PROXY, "%s handle dns", self) if not self.client.connected: warn(PROXY, "%s client closed after DNS", self) # The browser has already closed this connection, so abort return if answer.isFound(): self.ipaddr = answer.data[0] self.state = 'server' ...
16,024
def _main (): """USAGE: test/run.sh test/parsefile.py test.html""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) if sys.argv[1]=='-': f = sys.stdin else: f = file(sys.argv[1]) from bk.HtmlParser.htmllib import HtmlPrinter from bk.HtmlParser import htmlsax p = htmlsax.parser(HtmlPrinter()) #p.debug(1) ...
def _main (): """USAGE: test/run.sh test/parsefile.py test.html""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) if sys.argv[1] == '-': f = sys.stdin else: f = file(sys.argv[1]) from bk.HtmlParser.htmllib import HtmlPrinter from bk.HtmlParser import htmlsax p = htmlsax.parser(HtmlPrinter()) #p.debug(1...
16,025
def _main (): """USAGE: test/run.sh test/parsefile.py test.html""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) if sys.argv[1]=='-': f = sys.stdin else: f = file(sys.argv[1]) from bk.HtmlParser.htmllib import HtmlPrinter from bk.HtmlParser import htmlsax p = htmlsax.parser(HtmlPrinter()) #p.debug(1) ...
def _main (): """USAGE: test/run.sh test/parsefile.py test.html""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) if sys.argv[1]=='-': f = sys.stdin else: f = file(sys.argv[1]) from wc.HtmlParser.htmllib import HtmlPrinter from wc.HtmlParser import htmlsax p = htmlsax.parser(HtmlPrinter()) #p.debug(1) ...
16,026
def __init__ (self, client, request, headers, content, nofilter,compress): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter debug(ALWAYS, "Proxy:", `self.request`) self.method, self.url, protocol = self.request.split() scheme, ho...
def __init__ (self, client, request, headers, content, nofilter,compress): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol = self.request.split() schem...
16,027
def test_splitparam (self): """path parameter split test""" p = [ ("", ("", "")), ("/", ("/", "")), ("a", ("a", "")), ("a;", ("a", ";")), ("a/b;c/d;e", ("a/b;c/d", ";e")), ] for x in p: self._splitparam (self, x)
def test_splitparam (self): """path parameter split test""" p = [ ("", ("", "")), ("/", ("/", "")), ("a", ("a", "")), ("a;", ("a", "")), ("a/b;c/d;e", ("a/b;c/d", "e")), ] for x in p: self._splitparam (self, x)
16,028
def test_splitparam (self): """path parameter split test""" p = [ ("", ("", "")), ("/", ("/", "")), ("a", ("a", "")), ("a;", ("a", ";")), ("a/b;c/d;e", ("a/b;c/d", ";e")), ] for x in p: self._splitparam (self, x)
def test_splitparam (self): """path parameter split test""" p = [ ("", ("", "")), ("/", ("/", "")), ("a", ("a", "")), ("a;", ("a", ";")), ("a/b;c/d;e", ("a/b;c/d", ";e")), ] for x in p: self._splitparam (self, x)
16,029
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
16,030
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
16,031
def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re....
def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re....
16,032
def __init__(self, client, request, headers, content): self.client = client self.request = request self.headers = headers self.content = content try: self.method, url, protocol = split(request) except: self.error(400, _("Can't parse request")) if not url: self.error(400, _("Empty URL")) scheme, netloc = splittype(url) ...
def __init__(self, client, request, headers, content): self.client = client self.request = request self.headers = headers self.content = content try: self.method, url, protocol = split(request) except: self.error(400, _("Can't parse request")) if not url: self.error(400, _("Empty URL")) scheme, netloc = splittype(url) ...
16,033
def match_complete (self, pos, tagbuf): """ We know that the tag (and tag attributes) match. Now match the enclosing block. Return True on a match. """ if not self.enclosed: # no enclosed expression => match return True # put buf items together for matching items = tagbuf[pos:] data = wc.filter.xmlTags.tagbuf2data(item...
def match_complete (self, pos, tagbuf): """ We know that the tag (and tag attributes) match. Now match the enclosing block. Return True on a match. """ if not self.enclosed: # no enclosed expression => match return True # put buf items together for matching items = tagbuf[pos:] data = wc.filter.XmlTags.tagbuf2data(item...
16,034
def debug (logname, msg, *args, **kwargs): """ Log a debug message. return: None """ log = logging.getLogger(logname) if log.isEnabledFor(logging.DEBUG): _log(log.debug, msg, args, tb=kwargs.get("tb")) return True
def debug (logname, msg, *args, **kwargs): """ Log a debug message. return: None """ log = logging.getLogger(logname) if log.isEnabledFor(logging.DEBUG): _log(log.debug, msg, args, tb=kwargs.get("tb"))
16,035
def __init__ (self, client, url, form, protocol, clientheaders, status=200, msg=_('Ok'), localcontext=None, auth=''): """load a web configuration template and return response""" wc.log.debug(wc.LOG_GUI, "WebConfig %s %s", url, form) if isinstance(msg, unicode): msg = msg.encode("iso8859-1", "ignore") self.client = clie...
def __init__ (self, client, url, form, protocol, clientheaders, status=200, msg=_('Ok'), localcontext=None, auth=''): """load a web configuration template and return response""" wc.log.debug(wc.LOG_GUI, "WebConfig %s %s", url, form) if isinstance(msg, unicode): msg = msg.encode("iso8859-1", "ignore") self.client = clie...
16,036
def get_context (dirs, form, localcontext, lang): """Get template context, raise ImportError if not found. The context includes the given local context, plus all variables defined by the imported context module Evaluation of the context can set a different HTTP status. Returns tuple `(context, status)`""" # get templat...
def get_context (dirs, form, localcontext, hostname, lang): """Get template context, raise ImportError if not found. The context includes the given local context, plus all variables defined by the imported context module Evaluation of the context can set a different HTTP status. Returns tuple `(context, status)`""" # g...
16,037
def get_context (dirs, form, localcontext, lang): """Get template context, raise ImportError if not found. The context includes the given local context, plus all variables defined by the imported context module Evaluation of the context can set a different HTTP status. Returns tuple `(context, status)`""" # get templat...
def get_context (dirs, form, localcontext, lang): """Get template context, raise ImportError if not found. The context includes the given local context, plus all variables defined by the imported context module Evaluation of the context can set a different HTTP status. Returns tuple `(context, status)`""" # get templat...
16,038
def add_default_context (context, filename, lang): """add context variables used by all templates""" # rule macros path, dirs = wc.webgui.get_safe_template_path("macros/rules.html") rulemacros = wc.webgui.templatecache.templates[path] context_add(context, "rulemacros", rulemacros.macros) # standard macros path, dirs = ...
def add_default_context (context, filename, hostname, lang): """add context variables used by all templates""" # rule macros path, dirs = wc.webgui.get_safe_template_path("macros/rules.html") rulemacros = wc.webgui.templatecache.templates[path] context_add(context, "rulemacros", rulemacros.macros) # standard macros pat...
16,039
def add_default_context (context, filename, lang): """add context variables used by all templates""" # rule macros path, dirs = wc.webgui.get_safe_template_path("macros/rules.html") rulemacros = wc.webgui.templatecache.templates[path] context_add(context, "rulemacros", rulemacros.macros) # standard macros path, dirs = ...
def add_default_context (context, filename, lang): """add context variables used by all templates""" # rule macros path, dirs = wc.webgui.get_safe_template_path("macros/rules.html") rulemacros = wc.webgui.templatecache.templates[path] context_add(context, "rulemacros", rulemacros.macros) # standard macros path, dirs = ...
16,040
def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re....
def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re....
16,041
def test_multiheader_clen_toclient (self): self.start_test()
def test_multiheader_clen_toSrv (self): self.start_test()
16,042
def get_request_headers (self, content): port = self.server.socket.getsockname()[1] headers = [ "Host: localhost:%d" % port, "Proxy-Connection: close", ] if content: headers.append("Content-Length: %d" % len(content)) headers.append("Content-Length: %d" % (len(content)-5)) return headers
def get_request_headers (self, content): port = self.server.socket.getsockname()[1] headers = [ "Host: localhost:%d" % port, "Proxy-Connection: close", ] if content: headers.append("Content-Length: %d" % len(content)) headers.append("Content-Length: %d" % (len(content)-1)) return headers
16,043
def check_request_headers (self, request): num_found = 0 for header in request.headers: if header.lower().startswith("content-length:"): num_found += 1 self.assert_(num_found < 2)
def check_request_headers (self, request): num_found = 0 for header in request.headers: if header.lower().startswith("content-length:"): num_found += 1 self.assert_(num_found < 2)
16,044
def test_multiheader_clen_toserver (self): self.start_test()
def test_multiheader_clen_toClt (self): self.start_test()
16,045
def get_response_headers (self, content): return [ "Content-Type: text/plain", "Content-Length: %d" % len(content), "Content-Length: %d" % (len(content)-5), ]
def get_response_headers (self, content): return [ "Content-Type: text/plain", "Content-Length: %d" % len(content), "Content-Length: %d" % (len(content)-1), ]
16,046
def fix_configdata (): """fix install and config paths in the config file""" name = "_webcleaner_configdata.py" conffile = os.path.join(sys.prefix, "Lib", "site-packages", name) lines = [] for line in file(conffile): if line.startswith("install_") or line.startswith("config_"): lines.append(fix_install_path(line)) else...
def fix_configdata (): """fix install and config paths in the config file""" name = "_webcleaner2_configdata.py" conffile = os.path.join(sys.prefix, "Lib", "site-packages", name) lines = [] for line in file(conffile): if line.startswith("install_") or line.startswith("config_"): lines.append(fix_install_path(line)) els...
16,047
def has_header_value (headers, key, value): if has_attr(headers, "getallmatchingheaders"): # rfc822.Message() object for h in headers.getallmatchingheaders(key): if h.strip().lower() == value.lower(): return "True" return None return headers.get(key, '').lower() == value.lower()
def has_header_value (headers, key, value): if hasattr(headers, "getallmatchingheaders"): # rfc822.Message() object for h in headers.getallmatchingheaders(key): if h.strip().lower() == value.lower(): return "True" return None return headers.get(key, '').lower() == value.lower()
16,048
def __init__ (self, hostname, callback): global resolver if has_whitespace(hostname): # If there's whitespace, it's a copy/paste error hostname = re.sub(r'\s+', '', hostname) if ".." in hostname: # another possible typo hostname = re.sub(r'\.\.+', '.', hostname) if wc.ip.is_valid_ip(hostname): # it is already an ip adr...
def __init__ (self, hostname, callback): global resolver if has_whitespace(hostname): # If there's whitespace, it's a copy/paste error hostname = re.sub(r'\s+', '', hostname) if ".." in hostname: # another possible typo hostname = re.sub(r'\.\.+', '.', hostname) if wc.ip.is_valid_ip(hostname): # it is already an ip adr...
16,049
def process_headers (self): """look for headers and process them if found""" # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at...
def process_headers (self): """look for headers and process them if found""" # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at...
16,050
def process_headers (self): """look for headers and process them if found""" # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at...
def process_headers (self): """look for headers and process them if found""" # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at...
16,051
def is_rewrite (self): """return True iff this server will modify content""" for ro in wc.configuration.config['mime_content_rewriting']: if ro.match(self.headers.get('Content-Type', '')): return True return False
def is_rewrite (self): """return True iff this server will modify content""" for ro in wc.configuration.config['mime_content_rewriting']: if ro.match(self.headers.get('Content-Type', '')): return True return False
16,052
def process_content (self): """process server data: filter it and write it to client""" data = self.read(self.bytes_remaining) wc.log.debug(wc.LOG_PROXY, "%s process %d bytes", self, len(data)) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we'r...
def process_content (self): """process server data: filter it and write it to client""" data = self.read(self.bytes_remaining) wc.log.debug(wc.LOG_PROXY, "%s process %d bytes", self, len(data)) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we'r...
16,053
def process_content (self): """process server data: filter it and write it to client""" data = self.read(self.bytes_remaining) wc.log.debug(wc.LOG_PROXY, "%s process %d bytes", self, len(data)) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we'r...
def process_content (self): """process server data: filter it and write it to client""" data = self.read(self.bytes_remaining) wc.log.debug(wc.LOG_PROXY, "%s process %d bytes", self, len(data)) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we'r...
16,054
def process_client (self): """gets called on SSL tunneled connections, delegates server data directly to the client without filtering""" if not self.client: # delay return wc.log.debug(wc.LOG_PROXY, "%s write SSL tunneled data to client %s", self, self.client) self.client.write(self.read())
def process_client (self): """gets called on SSL tunneled connections, delegates server data directly to the client without filtering""" if not self.client: # delay return wc.log.debug(wc.LOG_PROXY, "%s write SSL tunneled data to client %s", self, self.client) self.client.write(self.read())
16,055
def __add (self, id, s, fuzzy): "Add a non-fuzzy translation to the dictionary." if not fuzzy and str: # check for multi-line values and munge them appropriately if '\n' in s: lines = s.rstrip().split('\n') s = NLSTR.join(lines) self.catalog[id] = s
def __add (self, id, s, fuzzy): "Add a non-fuzzy translation to the dictionary." if not fuzzy and s: # check for multi-line values and munge them appropriately if '\n' in s: lines = s.rstrip().split('\n') s = NLSTR.join(lines) self.catalog[id] = s
16,056
def _loadFile (self): # shamelessly cribbed from Python's Tools/i18n/msgfmt.py # 25-Mar-2003 Nathan R. Yergler (nathan@zope.org) # 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com)
def _loadFile (self): # shamelessly cribbed from Python's Tools/i18n/msgfmt.py # 25-Mar-2003 Nathan R. Yergler (nathan@zope.org) # 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com)
16,057
def write(self, s): pass
def write(self, s): pass
16,058
def __repr__ (self): """ Object description. """ extra = "" if hasattr(self, "persistent") and self.persistent: extra += "persistent " if hasattr(self, "addr") and self.addr and self.addr[1] != 80: portstr = ':%d' % self.addr[1] else: portstr = "" extra += '%s%s%s' % (self.hostname or self.addr[0], portstr, self.docume...
def __repr__ (self): """ Object description. """ extra = "" if hasattr(self, "persistent") and self.persistent: extra += "persistent " hasaddr = hasattr(self, "addr") and self.addr if hasattr(self, "hostname"): extra += self.hostname elif hasaddr: extra += self.addr[0] if hasaddr and self.addr[1] != 80: extra += ':%d' ...
16,059
def __init__ (self, client, request, headers, content, mime=None): self.client = client self.request = request self.headers = headers self.content = content self.mime = mime self.state = 'dns' self.method, self.url, protocol = self.request.split() # prepare DNS lookup if config['parentproxy']: self.hostname = config['p...
def __init__ (self, client, request, headers, content, mime=None): self.client = client self.request = request self.headers = headers self.content = content self.mime = mime self.state = 'dns' self.method, self.url, self.protocol = self.request.split() # prepare DNS lookup if config['parentproxy']: self.hostname = conf...
16,060
def addheader (self, name, value): """add given header name and value to the end of the header list. Multiple headers with the same name are supported""" self.headers.append("%s: %s\r" % (name, value))
def addheader (self, name, value): """add given header name and value to the end of the header list. Multiple headers with the same name are supported""" self.headers.append("%s: %s\r" % (name, value))
16,061
def process_headers (self): """read and filter client request headers""" # Two newlines ends headers i = self.recv_buffer.find('\r\n\r\n') if i < 0: return i += 4 # Skip over newline terminator # the first 2 chars are the newline of request fp = StringIO.StringIO(self.read(i)[2:]) msg = wc.proxy.Headers.WcMessage(fp) #...
def process_headers (self): """read and filter client request headers""" # Two newlines ends headers i = self.recv_buffer.find('\r\n\r\n') if i < 0: return i += 4 # Skip over newline terminator # the first 2 chars are the newline of request fp = StringIO.StringIO(self.read(i)[2:]) msg = wc.proxy.Headers.WcMessage(fp) #...
16,062
def test_htmltags (self): self.assertEqual("blink", check_spelling("blink")) self.assertEqual("blink", check_spelling("bllnk")) self.assertEqual("html", check_spelling("htmm")) self.assertEqual("hr", check_spelling("hu")) self.assertEqual("xmlns:a", check_spelling("xmlns:a")) self.assertEqual("heisead", check_spelling(...
def test_htmltags (self): self.assertEqual("blink", check_spelling("blink")) self.assertEqual("blink", check_spelling("bllnk")) self.assertEqual("html", check_spelling("htmm")) self.assertEqual("hr", check_spelling("hu")) self.assertEqual("xmlns:a", check_spelling("xmlns:a")) self.assertEqual("heisead", check_spelling(...
16,063
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,064
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,065
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,066
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,067
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,068
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
def _exec_form (form, lang): # reset info/error global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" info.clear() error.clear() res = [None] # proxy port if form.has_key('port'): _form_proxyport(_getval(form, 'port')) elif config['port']!=8080: _form_proxyport(8080) # ssl server port if form.ha...
16,069
def process_content (self): """read and filter client request content""" data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # Just pass everything through to the server # NOTE: It's possible to have 'chunked' encoding here, # and then the current system of counting bytes remaining # won't work;...
def process_content (self): """read and filter client request content""" data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # Just pass everything through to the server # NOTE: It's possible to have 'chunked' encoding here, # and then the current system of counting bytes remaining # won't work;...
16,070
def server_content (self, data): """The server received some content. Write it to the client.""" assert self.server, "%s server_content had no server" % self if data: self.write(data)
def server_content (self, data): """The server received some content. Write it to the client.""" assert self.server, "%s server_content(%s) had no server" % \ (self, data) if data: self.write(data)
16,071
def sighup_reload_config (signum, frame): """ Support reload on posix systems. Store timer for reloading configuration data. """ global pending_reload if not pending_reload: pending_reload = True wc.proxy.make_timer(1, reload_config)
def sighup_reload_config (signum, frame): """ Support reload on posix systems. Store timer for reloading configuration data. """ global pending_reload if not pending_reload: pending_reload = True import wc.proxy.timer wc.proxy.timer.make_timer(1, reload_config)
16,072
def finish (self, data, **attrs): # note: if attrs['blocked'] is True, then the blockdata is # already sent out if not attrs.has_key('imgsize_buf'): # do not block this image return data if attrs['imgsize_blocked']: # block this image return '' buf = attrs['imgsize_buf'] if buf.closed: return data buf.write(data) url =...
def finish (self, data, **attrs): # note: if attrs['blocked'] is True, then the blockdata is # already sent out if not attrs.has_key('imgsize_buf'): # do not block this image return data if attrs['imgsize_blocked']: # block this image return '' buf = attrs['imgsize_buf'] if buf.closed: return data buf.write(data) url =...
16,073
def process_read (self): if self.state in ('connect', 'client') and (method!='CONNECT'): # with http pipelining the client could send more data after # the initial request error(PROXY, 'server received data in %s state', self.state) error(PROXY, '%r', self.read()) return
def process_read (self): if self.state in ('connect', 'client') and \ (self.client and self.client.method!='CONNECT'): # with http pipelining the client could send more data after # the initial request error(PROXY, 'server received data in %s state', self.state) error(PROXY, '%r', self.read()) return
16,074
def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=...
def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=...
16,075
def jsScriptSrc (self, url, language): """Start a background download for <script src=""> tags""" assert self.state[0]=='parse', "non-parse state %s" % self.state ver = get_js_ver(language) if self.base_url: url = urlparse.urljoin(self.base_url, url) else: url = urlparse.urljoin(self.url, url) # unquote and norm url = ...
def jsScriptSrc (self, url, language): """Start a background download for <script src=""> tags""" assert self.state[0]=='parse', "non-parse state %s" % self.state ver = get_js_ver(language) if self.base_url: url = urlparse.urljoin(self.base_url, url) else: url = urlparse.urljoin(self.url, url) # unquote and norm url = ...
16,076
def testRdfDescription (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
def testRdfDescription (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
16,077
def testRdfDescription2 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
def testRdfDescription2 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
16,078
def testRdfDescription3 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
def testRdfDescription3 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?>
16,079
def proxyrequest2 (url, port): """raw request with PyOpenSSL""" from wc.proxy.Dispatcher import create_socket from wc.proxy.ssl import get_clientctx parts = urlparse.urlsplit(url) host = parts[1] #path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) sock = create_socket(socket.AF_INET, socket.SOCK_STREAM)...
def proxyrequest2 (url, port): """raw request with PyOpenSSL""" from wc.proxy.Dispatcher import create_socket from wc.proxy.ssl import get_clientctx parts = urlparse.urlsplit(url) host = parts[1] #path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) sock = create_socket(socket.AF_INET, socket.SOCK_STREAM)...
16,080
def proxyrequest2 (url, port): """raw request with PyOpenSSL""" from wc.proxy.Dispatcher import create_socket from wc.proxy.ssl import get_clientctx parts = urlparse.urlsplit(url) host = parts[1] #path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) sock = create_socket(socket.AF_INET, socket.SOCK_STREAM)...
def proxyrequest2 (url, port): """raw request with PyOpenSSL""" from wc.proxy.Dispatcher import create_socket from wc.proxy.ssl import get_clientctx parts = urlparse.urlsplit(url) host = parts[1] #path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) sock = create_socket(socket.AF_INET, socket.SOCK_STREAM)...
16,081
def _main (): """ USAGE: test/run.sh test/getssl.py <https url> """ if len(sys.argv) != 2: print _main.__doc__.strip() sys.exit(1) #request1(sys.argv[1]) import wc.configuration wc.configuration.config = wc.configuration.init("localconfig") port = wc.configuration.config['port'] sslport = wc.configuration.config['sslpo...
def _main (): """ USAGE: test/run.sh test/getssl.py <https url> """ if len(sys.argv) != 2: print _main.__doc__.strip() sys.exit(1) #request1(sys.argv[1]) import wc.configuration wc.configuration.config = wc.configuration.init("localconfig") port = wc.configuration.config['port'] sslport = wc.configuration.config['sslpo...
16,082
def _main (): """ USAGE: test/run.sh test/getssl.py <https url> """ if len(sys.argv) != 2: print _main.__doc__.strip() sys.exit(1) #request1(sys.argv[1]) import wc.configuration wc.configuration.config = wc.configuration.init("localconfig") port = wc.configuration.config['port'] sslport = wc.configuration.config['sslpo...
defproxyrequest2(sys.argv[1], sslport) _mainproxyrequest2(sys.argv[1], sslport) ():proxyrequest2(sys.argv[1], sslport) """proxyrequest2(sys.argv[1], sslport) USAGE:proxyrequest2(sys.argv[1], sslport) test/run.shproxyrequest2(sys.argv[1], sslport) test/getssl.pyproxyrequest2(sys.argv[1], sslport) <httpsproxyrequest2(sys...
16,083
def _main (): """ USAGE: test/run.sh test/getssl.py <https url> """ if len(sys.argv) != 2: print _main.__doc__.strip() sys.exit(1) #request1(sys.argv[1]) import wc.configuration wc.configuration.config = wc.configuration.init("localconfig") port = wc.configuration.config['port'] sslport = wc.configuration.config['sslpo...
def _main (): """ USAGE: test/run.sh test/getssl.py <https url> """ if len(sys.argv) != 2: print _main.__doc__.strip() sys.exit(1) #request1(sys.argv[1]) import wc.configuration wc.configuration.config = wc.configuration.init("localconfig") port = wc.configuration.config['port'] sslport = wc.configuration.config['sslpo...
16,084
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ print >> log, _("updating filters"), "..." chg = False baseurl = wconfig['baseurl']+"filter/" url = bas...
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ print >> log, _("updating filters"), "..." chg = False baseurl = wconfig['baseurl']+"filter/" url = bas...
16,085
def start_element (self, name, attrs): if name=='webcleaner': for key,val in attrs.items(): self.config[key] = val for key in ('port', 'sslport', 'parentproxyport', 'timeout', 'auth_ntlm', 'colorize', 'development', 'try_google', 'sslgateway',): self.config[key] = int(self.config[key]) if self.config['nofilterhosts'] i...
def start_element (self, name, attrs): if name=='webcleaner': for key,val in attrs.items(): self.config[key] = val for key in ('port', 'sslport', 'parentproxyport', 'timeout', 'auth_ntlm', 'colorize', 'development', 'try_google', 'sslgateway',): self.config[key] = int(self.config[key]) if self.config['nofilterhosts'] i...
16,086
def start_element (self, name, attrs): if name=='webcleaner': for key,val in attrs.items(): self.config[key] = val for key in ('port', 'sslport', 'parentproxyport', 'timeout', 'auth_ntlm', 'colorize', 'development', 'try_google', 'sslgateway',): self.config[key] = int(self.config[key]) if self.config['nofilterhosts'] i...
def start_element (self, name, attrs): if name=='webcleaner': for key,val in attrs.items(): self.config[key] = val for key in ('port', 'sslport', 'parentproxyport', 'timeout', 'auth_ntlm', 'colorize', 'development', 'try_google', 'sslgateway',): self.config[key] = int(self.config[key]) if self.config['nofilterhosts'] i...
16,087
def handle_local (self, is_public_doc=False): """handle local request by delegating it to the web configuration""" assert self.state=='receive' debug(PROXY, '%s handle_local', self) # reject invalid methods if self.method not in ['GET', 'POST', 'HEAD']: self.error(403, wc.i18n._("Invalid Method")) return # check admin ...
def handle_local (self, is_public_doc=False): """handle local request by delegating it to the web configuration""" assert self.state=='receive' debug(PROXY, '%s handle_local', self) # reject invalid methods if self.method not in ['GET', 'POST', 'HEAD']: self.error(403, wc.i18n._("Invalid Method")) return # check admin ...
16,088
def filter (self, data, attrs): """ Feed data to XML parser. """ if 'xmlrewriter_parser' not in attrs: return data p = attrs['xmlrewriter_parser'] f = attrs['xmlrewriter_filter'] try: p.feed(data) except xml.sax.SAXException, msg: wc.log.error(wc.LOG_FILTER, "XML filter error at %s: %s", attrs['url'], str(msg)) return ...
def filter (self, data, attrs): """ Feed data to XML parser. """ if 'xmlrewriter_parser' not in attrs: return data p = attrs['xmlrewriter_parser'] f = attrs['xmlrewriter_filter'] try: p.feed(data2) except xml.sax.SAXException: evalue = sys.exc_info()[1] wc.log.error(wc.LOG_FILTER, "XML filter error at %s: %s", attrs['u...
16,089
def filter (self, data, attrs): """ Feed data to XML parser. """ if 'xmlrewriter_parser' not in attrs: return data p = attrs['xmlrewriter_parser'] f = attrs['xmlrewriter_filter'] try: p.feed(data) except xml.sax.SAXException, msg: wc.log.error(wc.LOG_FILTER, "XML filter error at %s: %s", attrs['url'], str(msg)) return ...
def filter (self, data, attrs): """ Feed data to XML parser. """ if 'xmlrewriter_parser' not in attrs: return data p = attrs['xmlrewriter_parser'] f = attrs['xmlrewriter_filter'] try: p.feed(data) except xml.sax.SAXException, msg: wc.log.error(wc.LOG_FILTER, "XML filter error at %s: %s", attrs['url'], str(evalue)) retu...
16,090
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" rewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url): continue if rule.get_name()=='rewrite': rewrites.append(rule) elif rule.get_name()=='nocomments': opts['comments'] ...
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" rewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url): continue if rule.get_name()=='rewrite': rewrites.append(rule) elif rule.get_name()=='nocomments': opts['comments'] ...
16,091
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" rewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url): continue if rule.get_name()=='rewrite': rewrites.append(rule) elif rule.get_name()=='nocomments': opts['comments'] ...
def getAttrs (self, headers, url): """We need a separate filter instance for stateful filtering""" rewrites = [] opts = {'comments': 1, 'javascript': 0} for rule in self.rules: if not rule.appliesTo(url): continue if rule.get_name()=='rewrite': rewrites.append(rule) elif rule.get_name()=='nocomments': opts['comments'] ...
16,092
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.javascript = opts['javascript'] self.outbuf = StringIO() self.inbuf = StringIO(...
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.level = opts.get('level', 0) self.state = 'parse' self.waited = 0 self.rulestac...
16,093
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.javascript = opts['javascript'] self.outbuf = StringIO() self.inbuf = StringIO(...
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.javascript = opts['javascript'] self.outbuf = StringIO() self.inbuf = StringIO(...
16,094
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.javascript = opts['javascript'] self.outbuf = StringIO() self.inbuf = StringIO(...
def __init__ (self, rules, url, **opts): if wc.config['showerrors']: self.error = self._error self.warning = self._warning self.fatalError = self._fatalError HtmlParser.__init__(self) self.rules = rules self.comments = opts['comments'] self.javascript = opts['javascript'] self.outbuf = StringIO() self.inbuf = StringIO(...
16,095
def __repr__ (self): return "<HtmlFilter with rulestack %s>" % self.rulestack
def __repr__ (self): return "<HtmlFilter with rulestack %s>" % self.rulestack
16,096
def feed (self, data): if self.state=='parse': if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': return data = self.inbuf.getvalue() self.inbuf.close() self.inbuf = StringIO() if data: debug(NIGHTMARE, "HtmlFilter: feed", `data`) HtmlParser.feed(self, ...
def feed (self, data): if self.state=='parse': if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': return data = self.inbuf.getvalue() self.inbuf.close() self.inbuf = StringIO() if data: self._debug(NIGHTMARE, "feed", `data`) HtmlParser.feed(self, data) ...
16,097
def flush (self): if self.state=='wait': raise FilterException("HtmlFilter: still waiting for data") HtmlParser.flush(self)
def flush (self): if self.state=='wait': raise FilterException("HtmlFilter[%d]: still waiting for data"%self.level) HtmlParser.flush(self)
16,098
def replay (self, waitbuf): """call the handler functions again with buffer data""" for item in waitbuf: if item[0]==DATA: self.characters(item[1]) elif item[0]==STARTTAG: self.startElement(item[1], item[2]) elif item[0]==ENDTAG: self.endElement(item[1]) elif item[0]==COMMENT: self.comment(item[1])
def replay (self, waitbuf): """call the handler functions again with buffer data""" for item in waitbuf: if item[0]==DATA: self._data(item[1]) elif item[0]==STARTTAG: self.startElement(item[1], item[2]) elif item[0]==ENDTAG: self.endElement(item[1]) elif item[0]==COMMENT: self.comment(item[1])
16,099