rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
rules = filter(lambda r, u=url: r.appliesTo(u), self.rules) | 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):... | 496b0754393d38d24bf8ee7dfb8f4eac96d429d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/496b0754393d38d24bf8ee7dfb8f4eac96d429d2/Rewriter.py | |
val = attrs[name] | val = resolve_html_entities(attrs[name]) | 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 | 496b0754393d38d24bf8ee7dfb8f4eac96d429d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/496b0754393d38d24bf8ee7dfb8f4eac96d429d2/Rewriter.py |
self.jsEnv.executeScriptAsFunction(val, 0.0) | try: self.jsEnv.executeScriptAsFunction(val, 0.0) except jslib.error, msg: pass | 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 | 496b0754393d38d24bf8ee7dfb8f4eac96d429d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/496b0754393d38d24bf8ee7dfb8f4eac96d429d2/Rewriter.py |
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \ | return "%s, %02d %s %04d %02d:%02d:%02d GMT" % \ | 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... | 91f4415a82d9a741999cface705e7e40b0ff5c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/91f4415a82d9a741999cface705e7e40b0ff5c2e/date.py |
return "%s, %02d-%3s-%2d %02d:%02d:%02d GMT" % \ | return "%s, %02d-%s-%02d %02d:%02d:%02d GMT" % \ | 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... | 91f4415a82d9a741999cface705e7e40b0ff5c2e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/91f4415a82d9a741999cface705e7e40b0ff5c2e/date.py |
import wc.filter.rating wc.filter.rating.rating_cache_load() | def init (confdir=wc.ConfigDir): global config config = Configuration(confdir) import wc.filter.rating wc.filter.rating.rating_cache_load() return config | 90bab963a782a3081df5cfdb4c9d1570377d8b73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/90bab963a782a3081df5cfdb4c9d1570377d8b73/configuration.py | |
raise ParseException, _("unknown tag name %r") % name | wc.log.warn(wc.LOG_PROXY, _("unknown tag name %r"), name) self.error = name self.cmode = None | 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... | 90bab963a782a3081df5cfdb4c9d1570377d8b73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/90bab963a782a3081df5cfdb4c9d1570377d8b73/configuration.py |
self.cmode = None if self.rule is None: self.folder.end_data(name) | if self.error: if name == self.error: self.error = None | 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... | 90bab963a782a3081df5cfdb4c9d1570377d8b73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/90bab963a782a3081df5cfdb4c9d1570377d8b73/configuration.py |
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() | 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_data() | 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... | 90bab963a782a3081df5cfdb4c9d1570377d8b73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/90bab963a782a3081df5cfdb4c9d1570377d8b73/configuration.py |
if self.cmode: | if self.error: pass elif self.cmode: | 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) | 90bab963a782a3081df5cfdb4c9d1570377d8b73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/90bab963a782a3081df5cfdb4c9d1570377d8b73/configuration.py |
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`) | 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... | d8dceaf768957c7ad2f90280344041209e04324d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d8dceaf768957c7ad2f90280344041209e04324d/RewriteRule.py | |
debug(FILTER, "ro=%s", ro.pattern) | 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... | d8dceaf768957c7ad2f90280344041209e04324d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d8dceaf768957c7ad2f90280344041209e04324d/RewriteRule.py | |
debug(FILTER, "mo=%s", str(mo.groups())) | 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... | d8dceaf768957c7ad2f90280344041209e04324d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d8dceaf768957c7ad2f90280344041209e04324d/RewriteRule.py | |
debug(FILTER, "filtered tag %s attrs %s", tag, newattrs) | 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... | d8dceaf768957c7ad2f90280344041209e04324d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d8dceaf768957c7ad2f90280344041209e04324d/RewriteRule.py | |
self.jsForm(name, attrs.get('action'), attrs.get('target')) | self.jsForm(name, attrs.get('action', ''), attrs.get('target', '')) | 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('... | ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae/Rewriter.py |
self.buffer.append([DATA, self.jsfilter.flushbuf()]) | self.data.append(self.jsfilter.flushbuf()) | 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... | ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae/Rewriter.py |
if not script: return | 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... | ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae/Rewriter.py | |
self.jsEnv.attachListener(self) self.jsfilter = HtmlFilter(self.rules, self.document, comments=self.comments, javascript=self.javascript) self.jsEnv.executeScript(script, 0.0) self.jsEnv.detachListener(self) self.jsfilter.flush() self.buffer.append([DATA, self.jsfilter.flushbuf()]) self.buffer += self.jsfilter.buffer s... | if not script: return self.jsScript(script, 0.0) | 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... | ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ac3470728f7e970a92ce929b4fa85ae2f5e5d4ae/Rewriter.py |
self.socket.settimeout(wc.config['timeout']) | self.socket.settimeout(wc.configuration.config['timeout']) | 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... | bf76799da96a6df02ff60d023f221a0711d08765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bf76799da96a6df02ff60d023f221a0711d08765/SslServer.py |
if self.addr[1] != 80: | extra = "" if hasattr(self, "persistent") and self.persistent: extra += "persistent " if hasattr(self, "addr") and self.addr and self.addr[1] != 80: | 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... | bf76799da96a6df02ff60d023f221a0711d08765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bf76799da96a6df02ff60d023f221a0711d08765/SslServer.py |
else: portstr = '' extra = '%s%s' % (self.addr[0], portstr) | extra += '%s%s' % (self.addr[0], portstr) | 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... | bf76799da96a6df02ff60d023f221a0711d08765 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bf76799da96a6df02ff60d023f221a0711d08765/SslServer.py |
if log.isEnabledFor(logging.EXCEPTION): | if log.isEnabledFor(logging.ERROR): | 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")) | 94ceadcc5f9c4da5e1ae3caf0a770fa1751f25ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/94ceadcc5f9c4da5e1ae3caf0a770fa1751f25ac/log.py |
self.basedir = os.path.join(os.getcwd(), "wc", "magic", "tests", "data") | self.basedir = os.path.join(os.getcwd(), "wc", "magic", "tests") | def setUp (self): self.basedir = os.path.join(os.getcwd(), "wc", "magic", "tests", "data") | cdf4040d35f899fb063190c5215112d46cabf1f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/cdf4040d35f899fb063190c5215112d46cabf1f6/test_magic.py |
replace = _getval(form, 'rule_replace') if replace!=currule.replace: currule.replace = replace | replacement = _getval(form, 'rule_replace') if replacement!=currule.replacement: currule.replacement = replacement | 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... | 24974f3dbb0f6a990cc4805132f23cc3ecbcca7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/24974f3dbb0f6a990cc4805132f23cc3ecbcca7e/filterconfig_html.py |
new_url = self.scheme+"://"+answer.data | new_url = client.scheme+"://"+answer.data | 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' ... | e39e730d7098af632a7c860eda881635a87f3378 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/e39e730d7098af632a7c860eda881635a87f3378/ClientServerMatchmaker.py |
if sys.argv[1]=='-': | if sys.argv[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) ... | 5780642bc3a33799754cbc6f142399d2dc1d3b10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5780642bc3a33799754cbc6f142399d2dc1d3b10/parsefile.py |
from bk.HtmlParser.htmllib import HtmlPrinter from bk.HtmlParser import htmlsax | from wc.HtmlParser.htmllib import HtmlPrinter from wc.HtmlParser import htmlsax | 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) ... | 5780642bc3a33799754cbc6f142399d2dc1d3b10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5780642bc3a33799754cbc6f142399d2dc1d3b10/parsefile.py |
debug(ALWAYS, "Proxy:", `self.request`) | debug(BRING_IT_ON, "Proxy:", `self.request`) | 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... | 66661dc35f0c97769c0e026c2d852cc6c2c46bb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/66661dc35f0c97769c0e026c2d852cc6c2c46bb9/ClientServerMatchmaker.py |
("a;", ("a", ";")), ("a/b;c/d;e", ("a/b;c/d", ";e")), | ("a;", ("a", "")), ("a/b;c/d;e", ("a/b;c/d", "e")), | 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) | 267870176cbdd8a2ef1c955a05006f83e178dba7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/267870176cbdd8a2ef1c955a05006f83e178dba7/test_url.py |
self._splitparam (self, x) | self._splitparam(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) | 267870176cbdd8a2ef1c955a05006f83e178dba7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/267870176cbdd8a2ef1c955a05006f83e178dba7/test_url.py |
print >>log, "error fetching %s:"%url, msg | print >>log, wc.i18n._("error fetching %s")%url, msg print >>log, "...", wc.i18n._("done") | 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_... | 8832885efc90b0648f09097fc37307898435539d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8832885efc90b0648f09097fc37307898435539d/update.py |
print >>log, "error fetching", url | print >>log, wc.i18n._("error fetching %s")%url print >>log, "...", wc.i18n._("done") | 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_... | 8832885efc90b0648f09097fc37307898435539d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8832885efc90b0648f09097fc37307898435539d/update.py |
elif encoding and encoding!='identity' and not rewrite: | elif encoding and encoding!='identity' and rewrite: | 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.... | cd59f63da0532ca1a19064e9ec684853439d97ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/cd59f63da0532ca1a19064e9ec684853439d97ae/HttpServer.py |
self.document = document | self.document = document | 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) ... | b73f665228e46dbe21a8232efb7d60856bed8dec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b73f665228e46dbe21a8232efb7d60856bed8dec/ClientServerMatchmaker.py |
data = wc.filter.xmlTags.tagbuf2data(items, StringIO()).getvalue() | data = wc.filter.XmlTags.tagbuf2data(items, StringIO()).getvalue() | 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... | 3401adae72c624bdb38b3fac338ddefe687bc093 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/3401adae72c624bdb38b3fac338ddefe687bc093/RewriteRule.py |
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")) return True | 65df68086d73a485db39b645e48ea7d22cdb1acb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/65df68086d73a485db39b645e48ea7d22cdb1acb/log.py | |
get_context(dirs, form, localcontext, lang) | get_context(dirs, form, localcontext, hostname, lang) | 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... | 53b93c33d68ac5e26138e799e719ffc04c434bfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/53b93c33d68ac5e26138e799e719ffc04c434bfa/webconfig.py |
def get_context (dirs, form, localcontext, lang): | def get_context (dirs, form, localcontext, hostname, lang): | 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... | 53b93c33d68ac5e26138e799e719ffc04c434bfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/53b93c33d68ac5e26138e799e719ffc04c434bfa/webconfig.py |
add_default_context(context, dirs[-1], lang) | add_default_context(context, dirs[-1], hostname, lang) | 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... | 53b93c33d68ac5e26138e799e719ffc04c434bfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/53b93c33d68ac5e26138e799e719ffc04c434bfa/webconfig.py |
def add_default_context (context, filename, lang): | def add_default_context (context, filename, hostname, lang): | 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 = ... | 53b93c33d68ac5e26138e799e719ffc04c434bfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/53b93c33d68ac5e26138e799e719ffc04c434bfa/webconfig.py |
context_add(context, "baseurl", "http://localhost:%d/" % wc.configuration.config['port']) | port = wc.configuration.config['port'] context_add(context, "baseurl", "http://%s:%d/" % (hostname, port)) newport = wc.configuration.config.get('newport', port) context_add(context, "newbaseurl", "http://%s:%d/" % (hostname, newport)) | 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 = ... | 53b93c33d68ac5e26138e799e719ffc04c434bfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/53b93c33d68ac5e26138e799e719ffc04c434bfa/webconfig.py |
elif encoding and encoding!='identity': | elif encoding and encoding!='identity' and not rewrite: | 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.... | ef38c5f9723295584bfe497badcf732d2a0b1525 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ef38c5f9723295584bfe497badcf732d2a0b1525/HttpServer.py |
def test_multiheader_clen_toclient (self): | def test_multiheader_clen_toSrv (self): | def test_multiheader_clen_toclient (self): self.start_test() | ab4ecc1865c925ab117883a305d9d5f01f24ec39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ab4ecc1865c925ab117883a305d9d5f01f24ec39/test_multiheader.py |
headers.append("Content-Length: %d" % (len(content)-5)) | headers.append("Content-Length: %d" % (len(content)-1)) | 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 | ab4ecc1865c925ab117883a305d9d5f01f24ec39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ab4ecc1865c925ab117883a305d9d5f01f24ec39/test_multiheader.py |
class test_multiheader_clen_toserver (ProxyTest): | class test_multiheader_clen_toClt (ProxyTest): | 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) | ab4ecc1865c925ab117883a305d9d5f01f24ec39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ab4ecc1865c925ab117883a305d9d5f01f24ec39/test_multiheader.py |
def test_multiheader_clen_toserver (self): | def test_multiheader_clen_toClt (self): | def test_multiheader_clen_toserver (self): self.start_test() | ab4ecc1865c925ab117883a305d9d5f01f24ec39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ab4ecc1865c925ab117883a305d9d5f01f24ec39/test_multiheader.py |
"Content-Length: %d" % (len(content)-5), | "Content-Length: %d" % (len(content)-1), | def get_response_headers (self, content): return [ "Content-Type: text/plain", "Content-Length: %d" % len(content), "Content-Length: %d" % (len(content)-5), ] | ab4ecc1865c925ab117883a305d9d5f01f24ec39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ab4ecc1865c925ab117883a305d9d5f01f24ec39/test_multiheader.py |
name = "_webcleaner_configdata.py" | name = "_webcleaner2_configdata.py" | 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... | bb2db32e3e5530223a9ecdc8cfa15c71ad5cb7be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bb2db32e3e5530223a9ecdc8cfa15c71ad5cb7be/install-webcleaner.py |
if has_attr(headers, "getallmatchingheaders"): | if hasattr(headers, "getallmatchingheaders"): | 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() | e831eed981a003383bee5b98240512cf27a1c598 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/e831eed981a003383bee5b98240512cf27a1c598/__init__.py |
callback(DnsResponse('found', [hostname])) | callback(hostname, DnsResponse('found', [hostname])) | 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... | 10d78aeefe92466334cfb3a526cb1e362c5d1f2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/10d78aeefe92466334cfb3a526cb1e362c5d1f2a/dns_lookups.py |
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... | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py | ||
if not self.defer_data: | if self.defer_data: wc.log.debug(wc.LOG_PROXY, "deferring header data") else: | 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... | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py |
def _show_mime_replacement (self, url): self.statuscode = 302 response = "%s 302 %s" % (self.protocol, _("Moved Temporarily")) headers = wc.proxy.Headers.WcMessage() headers['Content-type'] = 'text/plain\r' headers['Location'] = url headers['Content-Length'] = '0\r' wc.log.debug(wc.LOG_PROXY, "%s headers\n%s", self, h... | 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 | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py | |
if data and self.statuscode != 407: | if self.statuscode != 407: | 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... | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py |
self.client.server_content(data) | if data: self.client.server_content(data) | 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... | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py |
wc.log.debug(wc.LOG_PROXY, "%s write SSL tunneled data to client %s", self, self.client) self.client.write(self.read()) | data = self.read() if data: wc.log.debug(wc.LOG_PROXY, "%s send %d bytes SSL tunneled data to client %s", self, len(data), self.client) self.client.write(data) | 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()) | 62269c4d81468ab25aef7067fb2e3ec8bbd33133 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/62269c4d81468ab25aef7067fb2e3ec8bbd33133/HttpServer.py |
if not fuzzy and str: | if not fuzzy and s: | 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 | 07f1316aa38074640a2637ac645f4d1a615224b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/07f1316aa38074640a2637ac645f4d1a615224b3/talgettext.py |
lno += True | lno += 1 | 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) | 07f1316aa38074640a2637ac645f4d1a615224b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/07f1316aa38074640a2637ac645f4d1a615224b3/talgettext.py |
print >> outfile, pot_header % {'time': time.ctime(), 'version': __version__} | pass | def write(self, s): pass | 07f1316aa38074640a2637ac645f4d1a615224b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/07f1316aa38074640a2637ac645f4d1a615224b3/talgettext.py |
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.document) | 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' % self.addr[1] if hasattr(self, "document"): extra += self.document | 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... | 842479cba16801c6173b3233a3013e7afe1eff89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/842479cba16801c6173b3233a3013e7afe1eff89/HttpServer.py |
self.method, self.url, protocol = self.request.split() | self.method, self.url, self.protocol = self.request.split() | 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... | aa1a015f670565db526f470673e912a55b8c3ea6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/aa1a015f670565db526f470673e912a55b8c3ea6/ClientServerMatchmaker.py |
self.headers.append("%s: %s\r" % (name, value)) | self.headers.append("%s: %s\r\n" % (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)) | 6ab0922dad2dfa606e6da3d25a1241961ffac006 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/6ab0922dad2dfa606e6da3d25a1241961ffac006/Headers.py |
wc.proxy.decoders.UnchunkStream.UnchunkStream()) | wc.proxy.decoder.UnchunkStream.UnchunkStream()) | 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) #... | aafcab0207cc695429aab4c86ba8b3e3a71fa9cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/aafcab0207cc695429aab4c86ba8b3e3a71fa9cc/HttpClient.py |
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("heisead")) | url = "unknown" self.assertEqual("blink", check_spelling("blink", url)) self.assertEqual("blink", check_spelling("bllnk", url)) self.assertEqual("html", check_spelling("htmm", url)) self.assertEqual("hr", check_spelling("hrr", url)) self.assertEqual("xmlns:a", check_spelling("xmlns:a", url)) self.assertEqual("heisead",... | 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(... | e678028bdfc6f49b1598b849140304bd3d88647a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/e678028bdfc6f49b1598b849140304bd3d88647a/test_spelling.py |
config['adminpass'] =u '' | config['adminpass'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
config['proxyuser'] = '' | config['proxyuser'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
config['proxypass'] = '' | config['proxypass'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
config['parentproxy'] = '' | config['parentproxy'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
config['parentproxyuser'] = '' | config['parentproxyuser'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
config['parentproxypass'] = '' | config['parentproxypass'] = u'' | 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... | 9faa79aa8270e0ad420dbdb0b5d75aafaa289d64 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9faa79aa8270e0ad420dbdb0b5d75aafaa289d64/config_html.py |
"http://localhost:%d/adminpass.html\r" % \ | "http://localhost:%d/adminpass.html\r" % \ | 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;... | eaa3e8d165cea3af1b5a7ec646600a5aa4cde063 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/eaa3e8d165cea3af1b5a7ec646600a5aa4cde063/HttpClient.py |
assert self.server, "%s server_content had no server" % self | assert self.server, "%s server_content(%s) had no server" % \ (self, data) | 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) | eaa3e8d165cea3af1b5a7ec646600a5aa4cde063 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/eaa3e8d165cea3af1b5a7ec646600a5aa4cde063/HttpClient.py |
wc.proxy.make_timer(1, reload_config) | import wc.proxy.timer wc.proxy.timer.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 wc.proxy.make_timer(1, reload_config) | 6b03631ab3b51d56d3fb5692a9ecd87f3fe7166a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/6b03631ab3b51d56d3fb5692a9ecd87f3fe7166a/configuration.py |
bk.log.error(wc.LOG_FILTER, "Empty image data found at %r (%r)", url, buf.getvalue()) else: attrs['imgsize_blocked'] = \ | return '' attrs['imgsize_blocked'] = \ | 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 =... | a560a7dc4e0e4176b308bdceefa2936092df33f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a560a7dc4e0e4176b308bdceefa2936092df33f7/ImageSize.py |
if self.state in ('connect', 'client') and (method!='CONNECT'): | if self.state in ('connect', 'client') and \ (self.client and self.client.method!='CONNECT'): | 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 | fcea44259b1d94652b0a0cada25763fdd4b91a6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/fcea44259b1d94652b0a0cada25763fdd4b91a6d/HttpServer.py |
self.base_url = strip_quotes(attrs['href']) | self.base_url = attrs['href'] if not urllib.splittype(self.base_url)[0]: self.base_url = "%s://%s" % \ (urllib.splittype(self.url)[0], self.base_url) | 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] +=... | b59797240acc502c65dc2183de8e33ea48f3212d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b59797240acc502c65dc2183de8e33ea48f3212d/HtmlParser.py |
host = stripsite(url)[0] | 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 = ... | b59797240acc502c65dc2183de8e33ea48f3212d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b59797240acc502c65dc2183de8e33ea48f3212d/HtmlParser.py | |
<description>bla </description> | <description><![CDATA[bla ]]></description> | def testRdfDescription (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?> | ae882b652ae62ad0507759dc05158de20a7b6d5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ae882b652ae62ad0507759dc05158de20a7b6d5a/test_xmlrewriter.py |
<description>bla </description> | <description><![CDATA[bla ]]></description> | def testRdfDescription2 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?> | ae882b652ae62ad0507759dc05158de20a7b6d5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ae882b652ae62ad0507759dc05158de20a7b6d5a/test_xmlrewriter.py |
<description>bla <img></description> | <description><![CDATA[bla <img>]]></description> | def testRdfDescription3 (self): self.filt("""<?xml version="1.0" encoding="ISO-8859-1"?> | ae882b652ae62ad0507759dc05158de20a7b6d5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ae882b652ae62ad0507759dc05158de20a7b6d5a/test_xmlrewriter.py |
addr = (socket.gethostbyname('localhost'), port) | 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)... | b993d0b77cae2854d10babd586b2abebd4c1acc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b993d0b77cae2854d10babd586b2abebd4c1acc7/getssl.py | |
sock.connect(addr) sock.do_handshake() sock.write('GET %s HTTP/1.1\r\n' % url) sock.write('Host: %s\r\n' % host) sock.write('\r\n') while True: try: print repr(sock.read(80)) except SSL.ZeroReturnError: | while True: try: sock.do_handshake() break except OpenSSL.SSL.WantReadError: time.sleep(0.2) except OpenSSL.SSL.WantWriteError: time.sleep(0.2) sock_write(sock, 'GET %s HTTP/1.1\r\n' % url) sock_write(sock, 'Host: %s\r\n' % host) sock_write(sock, '\r\n') while True: try: want_read(sock) except OpenSSL.SSL.ZeroReturnErr... | 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)... | b993d0b77cae2854d10babd586b2abebd4c1acc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b993d0b77cae2854d10babd586b2abebd4c1acc7/getssl.py |
port = wc.configuration.config['port'] sslport = wc.configuration.config['sslport'] | sslport = 443 print "Get %s (port %d)" % (sys.argv[1], sslport) | 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... | b993d0b77cae2854d10babd586b2abebd4c1acc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b993d0b77cae2854d10babd586b2abebd4c1acc7/getssl.py |
proxyrequest2(sys.argv[1], sslport) | 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... | b993d0b77cae2854d10babd586b2abebd4c1acc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b993d0b77cae2854d10babd586b2abebd4c1acc7/getssl.py | |
print "Get %s from localhost:%d" % (sys.argv[1], port) proxyrequest4(sys.argv[1], port) | 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... | b993d0b77cae2854d10babd586b2abebd4c1acc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b993d0b77cae2854d10babd586b2abebd4c1acc7/getssl.py | |
p = wc.configuration.ZapperParser(fullname, wconfig, compile_data=False) | p = wc.configuration.ZapperParser(fullname, compile_data=False) | 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... | 4576c58700609b1de3dad5c4835c381ef8762b78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4576c58700609b1de3dad5c4835c381ef8762b78/update.py |
self.config['nofilterhosts'] = ip.strhosts2map(strhosts) | self.config['nofilterhosts'] = strhosts.split(",") | 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... | d6c11c6cddade22c82a49d01ad165ac74b8d980b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d6c11c6cddade22c82a49d01ad165ac74b8d980b/__init__.py |
self.config['nofilterhosts'] = [Set(), []] | self.config['nofilterhosts'] = [] | 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... | d6c11c6cddade22c82a49d01ad165ac74b8d980b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d6c11c6cddade22c82a49d01ad165ac74b8d980b/__init__.py |
auth = ", ".join(get_challenges()) | auth = ", ".join(wc.proxy.auth.get_challenges()) | 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 ... | 1ed15b8d790f98edc8aaa1b852a5262ffb65d62a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1ed15b8d790f98edc8aaa1b852a5262ffb65d62a/HttpClient.py |
p.feed(data) except xml.sax.SAXException, msg: | p.feed(data2) except xml.sax.SAXException: evalue = sys.exc_info()[1] | 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 ... | f0d0e2022480b4ac7338ad70d5a4257c7498b331 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/f0d0e2022480b4ac7338ad70d5a4257c7498b331/XmlRewriter.py |
attrs['url'], str(msg)) | attrs['url'], str(evalue)) | 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 ... | f0d0e2022480b4ac7338ad70d5a4257c7498b331 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/f0d0e2022480b4ac7338ad70d5a4257c7498b331/XmlRewriter.py |
wait => Fetching additionally data in the background. Feeding new data in wait state raises a FilterException. When finished, the buffers look like data [---------|--------][-------][----------] | wait => this filter (or a recursive HtmlFilter used by javascript) is fetching additionally data in the background. Flushing data in wait state raises a FilterException. When finished for <script src="">, the buffers look like fed data chunks (example): [---------|--------][-------][----------][--... | 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'] ... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
waitbuf [--------] inbuf [-------------- ... | waitbuf: [--------] inbuf: [-------------- ... When finished with script data, the buffers look like XXX | 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'] ... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
self.javascript = opts['javascript'] | self.level = opts.get('level', 0) self.state = 'parse' self.waited = 0 self.rulestack = [] | 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(... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
self.state = 'parse' self.script = '' self.waited = 0 self.rulestack = [] | 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(... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py | |
if self.javascript: self.jsEnv = jslib.new_jsenv() self.output_counter = 0 self.popup_counter = 0 | self.js_filter = opts['javascript'] self.js_html = None self.js_src = 0 self.js_script = '' if self.js_filter: self.js_env = jslib.new_jsenv() self.js_output = 0 self.js_popup = 0 | 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(... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
return "<HtmlFilter with rulestack %s>" % self.rulestack | return "<HtmlFilter[%d] %s>" % (self.level, self.state) def _debug (self, level, *args): debug(level, "HtmlFilter[%d,%s]:"%(self.level,self.state), *args) def _debugbuf (self): """print debugging information about buffer status""" self._debug(NIGHTMARE, "self.buf", `self.buf`) self._debug(NIGHTMARE, "self.waitbuf",... | def __repr__ (self): return "<HtmlFilter with rulestack %s>" % self.rulestack | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
debug(NIGHTMARE, "HtmlFilter: feed", `data`) | self._debug(NIGHTMARE, "feed", `data`) | 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, ... | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
raise FilterException("HtmlFilter: still waiting for data") | raise FilterException("HtmlFilter[%d]: still waiting for data"%self.level) | def flush (self): if self.state=='wait': raise FilterException("HtmlFilter: still waiting for data") HtmlParser.flush(self) | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
self.characters(item[1]) | self._data(item[1]) | 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]) | 475def66113a258d59f287a283585f27e07dd77a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/475def66113a258d59f287a283585f27e07dd77a/Rewriter.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.