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): continue if rule.get_name()=='rewrite': rewrites.append(rule) elif rule.get_name()=='nocomments': opts['comments'] = 0 elif rule.get_name()=='javascript': opts['javascript'] = 1 # generate the HTML filter return {'filter': HtmlFilter(rewrites, url, **opts)} | 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" | "Fri" | "Sat" | "Sun" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec" Example: Sun, 06 Nov 1994 08:49:37 GMT """ year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timesecs) return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \ (wkdayname[wd], day, monthname[month], year, hh, mm, ss) | 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" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec" Example: Sunday, 06-Nov-94 08:49:37 GMT """ year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timesecs) return "%s, %02d-%3s-%2d %02d:%02d:%02d GMT" % \ (weekdayname[wd], day, monthname[month], year % 100, hh, mm, ss) | 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 character data elif name in _nestedtags: if self.rule is None: self.folder.fill_attrs(attrs, name) else: self.rule.fill_attrs(attrs, name) elif name == 'folder': self.folder.fill_attrs(attrs, name) else: raise ParseException, _("unknown tag name %r") % name | 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_data() | 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_data() | 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, 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 attrs.items(): ro = self.attrs.get(attr) if ro: debug(FILTER, "ro=%s", ro.pattern) mo = ro.search(val) if mo: if self.part==ATTR: # replace complete attr, and make it possible # for replacement to generate multiple attributes, # eg "a=b c=d" # XXX split does not honor quotes for f in self.replacement.split(): if '=' in self.replacement: k,v = f.split('=') newattrs[k] = v else: newattrs[self.replacement] = None elif self.part==ATTRVAL: # backreferences are replaced debug(FILTER, "mo=%s", str(mo.groups())) newattrs[attr] = mo.expand(self.replacement) else: error(FILTER, "Invalid part value %s" % str(self.part)) continue # nothing matched, just append the attribute as is newattrs[attr] = val debug(FILTER, "filtered tag %s attrs %s", tag, newattrs) return [STARTTAG, tag, newattrs] | 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, 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 attrs.items(): ro = self.attrs.get(attr) if ro: debug(FILTER, "ro=%s", ro.pattern) mo = ro.search(val) if mo: if self.part==ATTR: # replace complete attr, and make it possible # for replacement to generate multiple attributes, # eg "a=b c=d" # XXX split does not honor quotes for f in self.replacement.split(): if '=' in self.replacement: k,v = f.split('=') newattrs[k] = v else: newattrs[self.replacement] = None elif self.part==ATTRVAL: # backreferences are replaced debug(FILTER, "mo=%s", str(mo.groups())) newattrs[attr] = mo.expand(self.replacement) else: error(FILTER, "Invalid part value %s" % str(self.part)) continue # nothing matched, just append the attribute as is newattrs[attr] = val debug(FILTER, "filtered tag %s attrs %s", tag, newattrs) return [STARTTAG, tag, newattrs] | 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, 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 attrs.items(): ro = self.attrs.get(attr) if ro: debug(FILTER, "ro=%s", ro.pattern) mo = ro.search(val) if mo: if self.part==ATTR: # replace complete attr, and make it possible # for replacement to generate multiple attributes, # eg "a=b c=d" # XXX split does not honor quotes for f in self.replacement.split(): if '=' in self.replacement: k,v = f.split('=') newattrs[k] = v else: newattrs[self.replacement] = None elif self.part==ATTRVAL: # backreferences are replaced debug(FILTER, "mo=%s", str(mo.groups())) newattrs[attr] = mo.expand(self.replacement) else: error(FILTER, "Invalid part value %s" % str(self.part)) continue # nothing matched, just append the attribute as is newattrs[attr] = val debug(FILTER, "filtered tag %s attrs %s", tag, newattrs) return [STARTTAG, tag, newattrs] | 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, 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 attrs.items(): ro = self.attrs.get(attr) if ro: debug(FILTER, "ro=%s", ro.pattern) mo = ro.search(val) if mo: if self.part==ATTR: # replace complete attr, and make it possible # for replacement to generate multiple attributes, # eg "a=b c=d" # XXX split does not honor quotes for f in self.replacement.split(): if '=' in self.replacement: k,v = f.split('=') newattrs[k] = v else: newattrs[self.replacement] = None elif self.part==ATTRVAL: # backreferences are replaced debug(FILTER, "mo=%s", str(mo.groups())) newattrs[attr] = mo.expand(self.replacement) else: error(FILTER, "Invalid part value %s" % str(self.part)) continue # nothing matched, just append the attribute as is newattrs[attr] = val debug(FILTER, "filtered tag %s attrs %s", tag, newattrs) return [STARTTAG, tag, newattrs] | 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('name', attrs.get('id')) self.jsForm(name, attrs.get('action'), attrs.get('target')) elif tag=='script': lang = attrs.get('language', '').lower() scrtype = attrs.get('type', '').lower() if scrtype=='text/javascript' or \ lang.startswith('javascript') or \ not (lang or scrtype): self.jsScriptSrc(attrs.get('src'), lang) return self.buffer.append((STARTTAG, tag, attrs)) | 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)', language) if mo: ver = float(mo.group('num')) self.jsEnv.attachListener(self) self.jsfilter = HtmlFilter(self.rules, self.document, comments=self.comments, javascript=self.javascript) self.jsEnv.executeScript(script, ver) self.jsEnv.detachListener(self) self.jsfilter.flush() self.buffer.append([DATA, self.jsfilter.flushbuf()]) self.buffer += self.jsfilter.buffer self.jsfilter = None | 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.buffer and self.buffer[-1][0]==STARTTAG and \ self.buffer[1][1]=='script'): # there was a <script src="..."> already return del self.buffer[-1] if not script: return if script.startswith("<!--"): script = script[4:].strip() 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 self.jsfilter = None | 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 self.jsfilter = None | 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.buffer and self.buffer[-1][0]==STARTTAG and \ self.buffer[1][1]=='script'): # there was a <script src="..."> already return del self.buffer[-1] if not script: return if script.startswith("<!--"): script = script[4:].strip() 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 self.jsfilter = None | 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.proxy.ssl.get_clientctx(wc.configuration.config.configdir)) self.socket.settimeout(wc.config['timeout']) self.try_connect() self.socket.set_connect_state() | 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] + '...' return '<%s:%-8s %s>' % ('sslserver', self.state, extra) | 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] + '...' return '<%s:%-8s %s>' % ('sslserver', self.state, extra) | 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_replace') if replace!=currule.replace: currule.replace = replace info['rulereplace'] = True | 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' self.find_server() elif answer.isRedirect(): # Let's use a different hostname new_url = self.scheme+"://"+answer.data if self.port != 80: new_url += ':%d' % self.port new_url += self.document info(PROXY, "%s redirecting %r", self, new_url) self.state = 'done' # XXX find http version! ServerHandleDirectly( self.client, '%s 301 Moved Permanently' % self.protocol, 301, WcMessage(StringIO('Content-type: text/plain\r\n' 'Location: %s\r\n\r\n' % new_url)), i18n._('Host %s is an abbreviation for %s')%(hostname, answer.data)) else: # Couldn't look up the host, # close this connection self.state = 'done' self.client.error(504, i18n._("Host not found"), i18n._('Host %s not found .. %s')%(hostname, answer.data)) | 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) size = 1024 #size = 1 data = f.read(size) while data: p.feed(data) data = f.read(size) p.flush() | 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) size = 1024 #size = 1 data = f.read(size) while data: p.feed(data) data = f.read(size) p.flush() | 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, hostname, port, document = spliturl(self.url) # fix missing trailing / if not document: document = '/' # fix missing host headers for HTTP/1.1 if protocol=='HTTP/1.1' and not self.headers.has_key('host'): self.headers['Host'] = hostname if port!=80: self.headers['Host'] += ":%d"%port debug(HURT_ME_PLENTY, "Proxy: splitted url", scheme, hostname, port, document) if scheme=='file': # a blocked url is a local file:// link # this means we should _not_ use this proxy for local # file links :) mtype = mimetypes.guess_type(self.url)[0] config['requests']['valid'] += 1 config['requests']['blocked'] += 1 ServerHandleDirectly(self.client, 'HTTP/1.0 200 OK\r\n', 'Content-Type: %s\r\n\r\n'%(mtype or 'application/octet-stream'), open(document, 'rb').read()) return | 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_url(url) except IOError, msg: print >>log, "error fetching %s:"%url, msg return chg # remember all local config files filemap = {} for filename in wc.filterconf_files(wconfig.filterdir): filemap[os.path.basename(filename)] = filename # read md5sums for line in page.read().splitlines(): if "<" in line: print >>log, "error fetching", url return chg if not line: continue md5sum, filename = line.split() assert filename.endswith('.zap') fullname = os.path.join(wc.ConfigDir, filename) # compare checksums if filemap.has_key(filename): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest==md5sum: print >>log, wc.i18n._("filter %s not changed, ignoring")%filename continue print >>log, wc.i18n._("updating filter %s")%filename else: print >>log, wc.i18n._("adding new filter %s")%filename # parse new filter url = baseurl+filename page = open_url(url) p = wc.ZapperParser(fullname, wconfig, compile_data=False) p.parse(fp=page) page.close() if wconfig.merge_folder(p.folder, dryrun=dryrun, log=log): chg = True url = baseurl+"extern-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, wc.i18n._("error fetching %s:")%url, msg return chg lines = page.read().splitlines() page.close() for line in lines: if "<" in line: print >>log, wc.i18n._("error fetching %s:")%url, wc.i18n._("invalid content") return chg if not line: continue md5sum, filename = line.split() # XXX UNIX-generated md5sum filenames with subdirs are not portable fullname = os.path.join(wc.ConfigDir, filename) # compare checksums if os.path.exists(fullname): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest==md5sum: print >>log, wc.i18n._("extern filter %s not changed, ignoring")%filename continue print >>log, wc.i18n._("updating extern filter %s")%filename else: print >>log, wc.i18n._("adding new extern filter %s")%filename chg = True if not dryrun: url = baseurl+filename try: page = open_url(url) except IOError, msg: print >>log, wc.i18n._("error fetching %s:")%url, msg continue data = page.read() if not data: print >>log, wc.i18n._("error fetching %s:")%url, \ wc.i18n._("got no data") continue f = file(fullname, 'wb') f.write(data) f.close() return chg | 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_url(url) except IOError, msg: print >>log, "error fetching %s:"%url, msg return chg # remember all local config files filemap = {} for filename in wc.filterconf_files(wconfig.filterdir): filemap[os.path.basename(filename)] = filename # read md5sums for line in page.read().splitlines(): if "<" in line: print >>log, "error fetching", url return chg if not line: continue md5sum, filename = line.split() assert filename.endswith('.zap') fullname = os.path.join(wc.ConfigDir, filename) # compare checksums if filemap.has_key(filename): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest==md5sum: print >>log, wc.i18n._("filter %s not changed, ignoring")%filename continue print >>log, wc.i18n._("updating filter %s")%filename else: print >>log, wc.i18n._("adding new filter %s")%filename # parse new filter url = baseurl+filename page = open_url(url) p = wc.ZapperParser(fullname, wconfig, compile_data=False) p.parse(fp=page) page.close() if wconfig.merge_folder(p.folder, dryrun=dryrun, log=log): chg = True url = baseurl+"extern-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, wc.i18n._("error fetching %s:")%url, msg return chg lines = page.read().splitlines() page.close() for line in lines: if "<" in line: print >>log, wc.i18n._("error fetching %s:")%url, wc.i18n._("invalid content") return chg if not line: continue md5sum, filename = line.split() # XXX UNIX-generated md5sum filenames with subdirs are not portable fullname = os.path.join(wc.ConfigDir, filename) # compare checksums if os.path.exists(fullname): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest==md5sum: print >>log, wc.i18n._("extern filter %s not changed, ignoring")%filename continue print >>log, wc.i18n._("updating extern filter %s")%filename else: print >>log, wc.i18n._("adding new extern filter %s")%filename chg = True if not dryrun: url = baseurl+filename try: page = open_url(url) except IOError, msg: print >>log, wc.i18n._("error fetching %s:")%url, msg continue data = page.read() if not data: print >>log, wc.i18n._("error fetching %s:")%url, \ wc.i18n._("got no data") continue f = file(fullname, 'wb') f.write(data) f.close() return chg | 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.match(r'^((?:[^\r\n]+\r?\n)*\r?\n)', self.recv_buffer) if not m: return # handle continue requests (XXX should be in process_response?) response = self.response.split() if response and response[1] == '100': # it's a Continue request, so go back to waiting for headers # XXX for HTTP/1.1 clients, forward this self.state = 'response' return # filter headers self.headers = applyfilter(FILTER_RESPONSE_HEADER, rfc822.Message(StringIO(self.read(m.end()))), attrs=self.nofilter) # check for unusual compressed files if not self.headers.has_key('Content-Type') and \ (self.document.endswith(".bz2") or \ self.document.endswith(".tgz") or \ self.document.endswith(".gz")): gm = mimetypes.guess_type(self.document, False) if gm[0] and gm[1]: self.headers['Content-Encoding'] = gm[1] self.headers['Content-Type'] = gm[0] # will content be rewritten? rewrite = False for ro in config['mime_content_rewriting']: if ro.match(self.headers.get('Content-Type', "")): rewrite = True break #debug(HURT_ME_PLENTY, "S/Headers ", `self.headers.headers`) if self.headers.has_key('Content-Length'): if rewrite: remove_headers(self.headers, ['Content-Length']) self.bytes_remaining = None else: self.bytes_remaining = int(self.headers['Content-Length']) else: self.bytes_remaining = None | 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) netloc, document = splithost(netloc) hostname, port = splitport(netloc) if port is None: port = 80 if wc.proxy._PARENT_PROXY: self.hostname = wc.proxy._PARENT_PROXY self.port = wc.proxy._PARENT_PROXY_PORT self.document = url else: self.hostname = hostname self.port = port self.document = document # Temporary HACK if hostname == '_proxy': ServerHandleDirectly(self.client, 'HTTP/1.0 200 OK\r\n', 'Content-type: text/plain\r\n' '\r\n', print_socketlist()) return self.state = 'dns' dns_lookups.background_lookup(self.hostname, self.handle_dns) | 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(items, StringIO()).getvalue() return self.enclosed_ro.match(data) | 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 = client # we pretend to be the server self.connected = True headers = get_headers(url, status, auth, clientheaders) path = "" newstatus = None try: lang = wc.i18n.get_headers_lang(clientheaders) # get the template filename path, dirs, lang = wc.webgui.get_template_url(url, lang) if path.endswith('.html'): # get TAL context context, newstatus = \ get_context(dirs, form, localcontext, lang) if newstatus == 401 and status != newstatus: client.error(401, _("Authentication Required"), auth=wc.proxy.auth.get_challenges()) return # get (compiled) template template = wc.webgui.templatecache.templates[path] # expand template data = expand_template(template, context) # note: data is already encoded else: fp = file(path, 'rb') data = fp.read() fp.close() except IOError: wc.log.exception(wc.LOG_GUI, "Wrong path %r:", url) # XXX this can actually lead to a maximum recursion # error when client.error caused the exception client.error(404, _("Not Found")) return except StandardError: # catch standard exceptions and report internal error wc.log.exception(wc.LOG_GUI, "Template error: %r", path) client.error(500, _("Internal Error")) return # not catched builtin exceptions are: # SystemExit, StopIteration and all warnings | 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 template-specific context dict status = None modulepath = ".".join(['context'] + dirs[:-1]) template = dirs[-1].replace(".", "_") # this can raise an import error exec "from %s import %s as template_context" % (modulepath, template) # make TAL context context = {} if hasattr(template_context, "_form_reset"): template_context._form_reset() if hasattr(template_context, "_exec_form") and form is not None: # handle form action wc.log.debug(wc.LOG_GUI, "got form %s", form) status = template_context._exec_form(form, lang) # add form vars to context context_add(context, "form", form) # add default context values add_default_context(context, dirs[-1], lang) # augment the context attrs = [ x for x in dir(template_context) if not x.startswith('_') ] for attr in attrs: context_add(context, attr, getattr(template_context, attr)) # add local context if localcontext is not None: for key, value in localcontext.items(): context_add(context, key, value) return context, status | 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 template-specific context dict status = None modulepath = ".".join(['context'] + dirs[:-1]) template = dirs[-1].replace(".", "_") # this can raise an import error exec "from %s import %s as template_context" % (modulepath, template) # make TAL context context = {} if hasattr(template_context, "_form_reset"): template_context._form_reset() if hasattr(template_context, "_exec_form") and form is not None: # handle form action wc.log.debug(wc.LOG_GUI, "got form %s", form) status = template_context._exec_form(form, lang) # add form vars to context context_add(context, "form", form) # add default context values add_default_context(context, dirs[-1], lang) # augment the context attrs = [ x for x in dir(template_context) if not x.startswith('_') ] for attr in attrs: context_add(context, attr, getattr(template_context, attr)) # add local context if localcontext is not None: for key, value in localcontext.items(): context_add(context, key, value) return context, status | 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 = wc.webgui.get_safe_template_path("macros/standard.html") macros = wc.webgui.templatecache.templates[path] context_add(context, "macros", macros.macros) # used by navigation macro add_nav_context(context, filename) # page template name context_add(context, "filename", filename) # base url context_add(context, "baseurl", "http://localhost:%d/" % wc.configuration.config['port']) add_i18n_context(context, lang) | 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 = wc.webgui.get_safe_template_path("macros/standard.html") macros = wc.webgui.templatecache.templates[path] context_add(context, "macros", macros.macros) # used by navigation macro add_nav_context(context, filename) # page template name context_add(context, "filename", filename) # base url context_add(context, "baseurl", "http://localhost:%d/" % wc.configuration.config['port']) add_i18n_context(context, lang) | 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.match(r'^((?:[^\r\n]+\r?\n)*\r?\n)', self.recv_buffer) if not m: return # handle continue requests (XXX should be in process_response?) response = self.response.split() if response and response[1] == '100': # it's a Continue request, so go back to waiting for headers # XXX for HTTP/1.1 clients, forward this self.state = 'response' return # filter headers self.headers = applyfilter(FILTER_RESPONSE_HEADER, rfc822.Message(StringIO(self.read(m.end()))), attrs=self.nofilter) # check for unusual compressed files if not self.headers.has_key('Content-Type') and \ (self.document.endswith(".bz2") or \ self.document.endswith(".tgz") or \ self.document.endswith(".gz")): gm = mimetypes.guess_type(self.document, False) if gm[0] and gm[1]: self.headers['Content-Encoding'] = gm[1] self.headers['Content-Type'] = gm[0] # will content be rewritten? rewrite = False for ro in config['mime_content_rewriting']: if ro.match(self.headers.get('Content-Type', "")): rewrite = True break #debug(HURT_ME_PLENTY, "S/Headers ", `self.headers.headers`) if self.headers.has_key('Content-Length'): if rewrite: remove_headers(self.headers, ['Content-Length']) self.bytes_remaining = None else: self.bytes_remaining = int(self.headers['Content-Length']) else: self.bytes_remaining = None | 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: lines.append(line) f = file(conffile, "w") f.write("".join(lines)) f.close() | 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 adress callback(DnsResponse('found', [hostname])) return self.erroranswer = None # set if one answer failed self.hostname = hostname self.callback = callback self.queries = [hostname] # all queries to be made self.answers = {} # Map hostname to DNS answer # How long do we wait before trying another expansion? self.delay = 3 if not dnscache.well_known_hosts.has_key(hostname): for domain in resolver.search: self.queries.append(hostname + domain) if hostname.find('.') < 0: # If there's no dot, we should try expanding patterns for pattern in resolver.search_patterns: self.queries.append(pattern % hostname) # it is likely that search_domains matter self.delay = 0.2 self.requests = self.queries[1:] # queries we haven't yet made # Issue the primary request wc.proxy.make_timer(0, lambda: dnscache.lookup(hostname, self.handle_dns)) # and then start another request as well if it's needed if self.delay < 1 and len(self.requests) > 0: wc.proxy.make_timer(self.delay, self.handle_issue_request) | 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 a time # until we get to a blank line... m = re.match(r'^((?:[^\r\n]+\r?\n)*\r?\n)', self.recv_buffer) if not m: return # get headers fp = StringIO.StringIO(self.read(m.end())) msg = wc.proxy.Headers.WcMessage(fp) # put unparsed data (if any) back to the buffer msg.rewindbody() self.recv_buffer = fp.read() + self.recv_buffer fp.close() # make a copy for later serverheaders = msg.copy() wc.log.debug(wc.LOG_PROXY, "%s server headers\n%s", self, serverheaders) if self.statuscode == 100: # it's a Continue request, so go back to waiting for headers # XXX for HTTP/1.1 clients, forward this self.state = 'response' return self.set_persistent(msg, wc.proxy.ServerPool.serverpool.http_versions[self.addr]) self.attrs = wc.filter.get_filterattrs(self.url, [wc.filter.FILTER_RESPONSE_HEADER], clientheaders=self.client.headers, serverheaders=serverheaders) try: self.headers = \ wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_HEADER, msg, "finish", self.attrs) except wc.filter.FilterRating, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterRating from header: %s", self, msg) if msg == wc.filter.Rating.MISSING: # still have to look at content self.defer_data = True else: self._show_rating_deny(str(msg)) return #except wc.filter.FilterMime, msg: # wc.log.debug(wc.LOG_PROXY, "%s FilterMime from header: %s", # self, msg) # self._show_mime_replacement(str(msg)) # return if self.statuscode in (301, 302): location = self.headers.get('Location') if location: host = wc.url.spliturl(location)[1] if host in wc.proxy.dns_lookups.resolver.localhosts: self.handle_error(_('redirection to localhost')) return self.mangle_response_headers() if self.statuscode in (204, 304) or self.method == 'HEAD': # these response codes indicate no content self.state = 'recycle' else: self.state = 'content' self.attrs = wc.filter.get_filterattrs(self.url, FilterLevels, clientheaders=self.client.headers, serverheaders=serverheaders, headers=self.headers) wc.log.debug(wc.LOG_PROXY, "%s filtered headers %s", self, self.headers) if not self.defer_data: self.client.server_response(self, self.response, self.statuscode, self.headers) # note: self.client could be None here | 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 a time # until we get to a blank line... m = re.match(r'^((?:[^\r\n]+\r?\n)*\r?\n)', self.recv_buffer) if not m: return # get headers fp = StringIO.StringIO(self.read(m.end())) msg = wc.proxy.Headers.WcMessage(fp) # put unparsed data (if any) back to the buffer msg.rewindbody() self.recv_buffer = fp.read() + self.recv_buffer fp.close() # make a copy for later serverheaders = msg.copy() wc.log.debug(wc.LOG_PROXY, "%s server headers\n%s", self, serverheaders) if self.statuscode == 100: # it's a Continue request, so go back to waiting for headers # XXX for HTTP/1.1 clients, forward this self.state = 'response' return self.set_persistent(msg, wc.proxy.ServerPool.serverpool.http_versions[self.addr]) self.attrs = wc.filter.get_filterattrs(self.url, [wc.filter.FILTER_RESPONSE_HEADER], clientheaders=self.client.headers, serverheaders=serverheaders) try: self.headers = \ wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_HEADER, msg, "finish", self.attrs) except wc.filter.FilterRating, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterRating from header: %s", self, msg) if msg == wc.filter.Rating.MISSING: # still have to look at content self.defer_data = True else: self._show_rating_deny(str(msg)) return #except wc.filter.FilterMime, msg: # wc.log.debug(wc.LOG_PROXY, "%s FilterMime from header: %s", # self, msg) # self._show_mime_replacement(str(msg)) # return if self.statuscode in (301, 302): location = self.headers.get('Location') if location: host = wc.url.spliturl(location)[1] if host in wc.proxy.dns_lookups.resolver.localhosts: self.handle_error(_('redirection to localhost')) return self.mangle_response_headers() if self.statuscode in (204, 304) or self.method == 'HEAD': # these response codes indicate no content self.state = 'recycle' else: self.state = 'content' self.attrs = wc.filter.get_filterattrs(self.url, FilterLevels, clientheaders=self.client.headers, serverheaders=serverheaders, headers=self.headers) wc.log.debug(wc.LOG_PROXY, "%s filtered headers %s", self, self.headers) if not self.defer_data: self.client.server_response(self, self.response, self.statuscode, self.headers) # note: self.client could be None here | 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, headers) self.client.server_response(self, response, self.statuscode, headers) if not self.client: return self.client.server_close(self) self.client = None self.state = 'recycle' self.persistent = False self.close() | 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're done self.bytes_remaining -= len(data) wc.log.debug(wc.LOG_PROXY, "%s %d bytes remaining", self, self.bytes_remaining) is_closed = False for decoder in self.decoders: data = decoder.decode(data) wc.log.debug(wc.LOG_PROXY, "%s have run decoder %s", self, decoder) if not is_closed and decoder.closed: is_closed = True try: data = wc.filter.applyfilters(FilterLevels, data, "filter", self.attrs) except wc.filter.FilterWait, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterWait %s", self, msg) except wc.filter.FilterRating, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterRating from content %s", self, msg) self._show_rating_deny(str(msg)) return except wc.filter.FilterProxyError, e: self.client.error(e.status, e.msg, txt=e.text) self.handle_error("filter proxy error") return underflow = self.bytes_remaining is not None and \ self.bytes_remaining < 0 if underflow: wc.log.warn(wc.LOG_PROXY, _("server received %d bytes more than content-length"), (-self.bytes_remaining)) if data and self.statuscode != 407: if self.defer_data: self.defer_data = False self.client.server_response(self, self.response, self.statuscode, self.headers) if not self.client: return self.client.server_content(data) if is_closed or self.bytes_remaining == 0: # either we ran out of bytes, or the decoder says we're done self.state = 'recycle' | 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're done self.bytes_remaining -= len(data) wc.log.debug(wc.LOG_PROXY, "%s %d bytes remaining", self, self.bytes_remaining) is_closed = False for decoder in self.decoders: data = decoder.decode(data) wc.log.debug(wc.LOG_PROXY, "%s have run decoder %s", self, decoder) if not is_closed and decoder.closed: is_closed = True try: data = wc.filter.applyfilters(FilterLevels, data, "filter", self.attrs) except wc.filter.FilterWait, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterWait %s", self, msg) except wc.filter.FilterRating, msg: wc.log.debug(wc.LOG_PROXY, "%s FilterRating from content %s", self, msg) self._show_rating_deny(str(msg)) return except wc.filter.FilterProxyError, e: self.client.error(e.status, e.msg, txt=e.text) self.handle_error("filter proxy error") return underflow = self.bytes_remaining is not None and \ self.bytes_remaining < 0 if underflow: wc.log.warn(wc.LOG_PROXY, _("server received %d bytes more than content-length"), (-self.bytes_remaining)) if data and self.statuscode != 407: if self.defer_data: self.defer_data = False self.client.server_response(self, self.response, self.statuscode, self.headers) if not self.client: return self.client.server_content(data) if is_closed or self.bytes_remaining == 0: # either we ran out of bytes, or the decoder says we're done self.state = 'recycle' | 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 ([email protected]) # 14-Apr-2003 Hacked by Barry Warsaw ([email protected]) | 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.document) if hasattr(self, "client") and self.client: extra += " client" #if len(extra) > 46: extra = extra[:43] + '...' return '<%s:%-8s %s>' % ('server', self.state, extra) | 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['parentproxy'] self.port = config['parentproxyport'] self.document = self.url if config['parentproxycreds']: auth = config['parentproxycreds'] self.headers['Proxy-Authorization'] = "%s\r"%auth else: self.hostname = client.hostname self.port = client.port self.document = document_quote(client.document) assert self.hostname # start DNS lookup dns_lookups.background_lookup(self.hostname, self.handle_dns) | 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) # put unparsed data (if any) back to the buffer msg.rewindbody() self.recv_buffer = fp.read() + self.recv_buffer fp.close() wc.log.debug(wc.LOG_PROXY, "%s client headers \n%s", self, msg) self.fix_request_headers(msg) clientheaders = msg.copy() stage = wc.filter.STAGE_REQUEST_HEADER self.attrs = wc.filter.get_filterattrs(self.url, [stage], clientheaders=clientheaders, headers=msg) self.set_persistent(msg, self.http_ver) self.mangle_request_headers(msg) self.compress = wc.proxy.Headers.client_set_encoding_headers(msg) # filter headers self.headers = wc.filter.applyfilter(stage, msg, "finish", self.attrs) # add decoders self.decoders = [] # if content-length header is missing, assume zero length self.bytes_remaining = \ wc.proxy.Headers.get_content_length(self.headers, 0) # chunked encoded if self.headers.has_key('Transfer-Encoding'): # XXX don't look at value, assume chunked encoding for now wc.log.debug(wc.LOG_PROXY, '%s Transfer-encoding %r', self, self.headers['Transfer-encoding']) self.decoders.append( wc.proxy.decoders.UnchunkStream.UnchunkStream()) wc.proxy.Headers.client_remove_encoding_headers(self.headers) self.bytes_remaining = None if self.bytes_remaining is None: self.persistent = False if not self.hostname and self.headers.has_key('Host'): if self.method == 'CONNECT': defaultport = 443 else: defaultport = 80 host = self.headers['Host'] self.hostname, self.port = urllib.splitnport(host, defaultport) if not self.hostname: wc.log.error(wc.LOG_PROXY, "%s missing hostname in request", self) self.error(400, _("Bad Request")) # local request? if self.hostname in wc.proxy.dns_lookups.resolver.localhosts and \ self.port == wc.configuration.config['port']: # this is a direct proxy call, jump directly to content self.state = 'content' return # add missing host headers for HTTP/1.1 if not self.headers.has_key('Host'): wc.log.warn(wc.LOG_PROXY, "%s request without Host header encountered", self) if self.port != 80: self.headers['Host'] = "%s:%d\r" % (self.hostname, self.port) else: self.headers['Host'] = "%s\r" % self.hostname if wc.configuration.config["proxyuser"]: creds = wc.proxy.auth.get_header_credentials(self.headers, 'Proxy-Authorization') if not creds: auth = ", ".join(wc.proxy.auth.get_challenges()) self.error(407, _("Proxy Authentication Required"), auth=auth) return if 'NTLM' in creds: if creds['NTLM'][0]['type'] == \ wc.proxy.auth.ntlm.NTLMSSP_NEGOTIATE: attrs = { 'host': creds['NTLM'][0]['host'], 'domain': creds['NTLM'][0]['domain'], 'type': wc.proxy.auth.ntlm.NTLMSSP_CHALLENGE, } auth = ",".join(wc.proxy.auth.get_challenges(**attrs)) self.error(407, _("Proxy Authentication Required"), auth=auth) return # XXX the data=None argument should hold POST data if not wc.proxy.auth.check_credentials(creds, username=wc.configuration.config['proxyuser'], password_b64=wc.configuration.config['proxypass'], uri=wc.proxy.auth.get_auth_uri(self.url), method=self.method, data=None): wc.log.warn(wc.LOG_AUTH, "Bad proxy authentication from %s", self.addr[0]) auth = ", ".join(wc.proxy.auth.get_challenges()) self.error(407, _("Proxy Authentication Required"), auth=auth) return if self.method in ['OPTIONS', 'TRACE'] and \ wc.proxy.Headers.client_get_max_forwards(self.headers) == 0: # XXX display options ? self.state = 'done' headers = wc.proxy.Headers.WcMessage() headers['Content-Type'] = 'text/plain\r' wc.proxy.ServerHandleDirectly.ServerHandleDirectly(self, '%s 200 OK' % self.protocol, 200, headers, '') return if self.needs_redirect: self.state = 'done' headers = wc.proxy.Headers.WcMessage() headers['Content-Type'] = 'text/plain\r' headers['Location'] = '%s\r' % self.url wc.proxy.ServerHandleDirectly.ServerHandleDirectly(self, '%s 302 Found' % self.protocol, 302, headers, '') return self.state = 'content' | 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", check_spelling("heisead", url)) | 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("heisead")) | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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.has_key('sslport'): _form_sslport(_getval(form, 'sslport')) elif config['sslport']!=8443: _form_sslport(8443) # ssl gateway if form.has_key('sslgateway'): _form_sslgateway(1) else: _form_sslgateway(0) # admin user if form.has_key('adminuser'): _form_adminuser(_getval(form, 'adminuser').strip(), res) elif config['adminuser']: config['adminuser'] = u'' config.write_proxyconf() info['adminuser'] = True # admin pass if form.has_key('adminpass'): val = _getval(form, 'adminpass') # ignore dummy values if val!=u'__dummy__': _form_adminpass(base64.encodestring(val).strip(), res) elif config['adminpass']: config['adminpass'] =u '' config.write_proxyconf() info['adminpass'] = True if config['adminuser']: res[0] = 401 # proxy user if form.has_key('proxyuser'): _form_proxyuser(_getval(form, 'proxyuser').strip(), res) elif config['proxyuser']: config['proxyuser'] = '' config.write_proxyconf() info['proxyuser'] = True # proxy pass if form.has_key('proxypass'): val = _getval(form, 'proxypass') # ignore dummy values if val!=u'__dummy__': _form_proxypass(base64.encodestring(val).strip(), res) elif config['proxypass']: config['proxypass'] = '' config.write_proxyconf() info['proxypass'] = True # ntlm authentication if form.has_key('auth_ntlm'): if not config['auth_ntlm']: config['auth_ntlm'] = 1 config.write_proxyconf() info['auth_ntlm'] = True elif config['auth_ntlm']: config['auth_ntlm'] = 0 config.write_proxyconf() info['auth_ntlm'] = True # use google cache if form.has_key('try_google'): if not config['try_google']: config['try_google'] = 1 config.write_proxyconf() info['try_google'] = True elif config['try_google']: config['try_google'] = 0 config.write_proxyconf() info['try_google'] = True # parent proxy host if form.has_key('parentproxy'): _form_parentproxy(_getval(form, 'parentproxy').strip()) elif config['parentproxy']: config['parentproxy'] = '' config.write_proxyconf() info['parentproxy'] = True # parent proxy port if form.has_key('parentproxyport'): _form_parentproxyport(_getval(form, 'parentproxyport')) elif config['parentproxyport'] != 3128: config['parentproxyport'] = 3128 config.write_proxyconf() info['parentproxyport'] = True # parent proxy user if form.has_key('parentproxyuser'): _form_parentproxyuser(_getval(form, 'parentproxyuser').strip()) elif config['parentproxyuser']: config['parentproxyuser'] = '' config.write_proxyconf() info['parentproxyuser'] = True # parent proxy pass if form.has_key('parentproxypass'): val = _getval(form, 'parentproxypass') # ignore dummy values if val!=u'__dummy__': _form_parentproxypass(base64.encodestring(val).strip()) elif config['parentproxypass']: config['parentproxypass'] = '' config.write_proxyconf() info['parentproxypass'] = True # timeout if form.has_key('timeout'): _form_timeout(_getval(form, 'timeout')) elif config['timeout']!=30: config['timeout'] = 30 config.write_proxyconf() info['timeout'] = True # filter modules _form_filtermodules(form) # allowed hosts if form.has_key('addallowed') and form.has_key('newallowed'): _form_addallowed(_getval(form, 'newallowed').strip()) elif form.has_key('delallowed') and form.has_key('allowedhosts'): _form_delallowed(form) # no filter hosts if form.has_key('addnofilter') and form.has_key('newnofilter'): _form_addnofilter(_getval(form, 'newnofilter').strip()) elif form.has_key('delnofilter') and form.has_key('nofilterhosts'): _form_delnofilter(form) return res[0] | 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; we have to deal with chunks self.bytes_remaining -= len(data) is_closed = False for decoder in self.decoders: data = decoder.decode(data) if not is_closed: is_closed = decoder.closed data = wc.filter.applyfilters(FilterLevels, data, "filter", self.attrs) self.content += data underflow = self.bytes_remaining is not None and \ self.bytes_remaining < 0 if underflow: wc.log.warn(wc.LOG_PROXY, "client received %d bytes more than content-length", -self.bytes_remaining) if is_closed or self.bytes_remaining <= 0: data = wc.filter.applyfilters(FilterLevels, "", "finish", self.attrs) self.content += data if self.content and not self.headers.has_key('Content-Length'): self.headers['Content-Length'] = "%d\r" % len(self.content) # We're done reading content self.state = 'receive' is_local = self.hostname in \ wc.proxy.dns_lookups.resolver.localhosts and \ self.port in (wc.configuration.config['port'], wc.configuration.config['sslport']) if is_local: is_public_doc = self.allow.public_document(self.document) if wc.configuration.config['adminuser'] and \ not wc.configuration.config['adminpass']: if is_local and is_public_doc: self.handle_local(is_public_doc=is_public_doc) else: # ignore request, must init admin password self.headers['Location'] = \ "http://localhost:%d/adminpass.html\r" % \ wc.configuration.config['port'] self.error(302, _("Moved Temporarily")) elif is_local: # this is a direct proxy call self.handle_local(is_public_doc=is_public_doc) else: self.server_request() | 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 = attrs['url'] pos = buf.tell() if pos <= 0: bk.log.error(wc.LOG_FILTER, "Empty image data found at %r (%r)", url, buf.getvalue()) else: attrs['imgsize_blocked'] = \ not self.check_sizes(buf, attrs['imgsize_sizes'], url, finish=True) data = buf.getvalue() buf.close() if attrs['imgsize_blocked']: return self.blockdata return data | 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] += 1 if self.state[0]=='wait': self.waitbuf.append([STARTTAG, tag, attrs]) return if tag=="meta": if attrs.get('http-equiv', '').lower() =='content-rating': rating = resolve_html_entities(attrs.get('content', '')) # note: always put this in the cache, since this overrides # any http header setting, and page content changes more # often rating_add(self.url, rating_parse(rating)) elif tag=="body": if self.ratings: # headers finished, check rating data for rule in self.ratings: msg = rating_allow(self.url, rule) if msg: raise FilterRating(msg) self.ratings = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) self._debug("using base url %r", self.base_url) # search for and prevent known security flaws in HTML self.security.scan_start_tag(tag, attrs, self) # look for filter rules which apply self.filterStartElement(tag, attrs) # if rule stack is empty, write out the buffered data if not self.rulestack and not self.javascript: self.buf2data() | 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 = url_norm(url) self.state = ('wait', url) self.waited = 1 self.js_src = True self.js_client = HttpProxyClient(self.jsScriptData, (url, ver)) host = stripsite(url)[0] headers = get_wc_client_headers(host) # note: some javascript servers do not specify content encoding # so only accept non-encoded content here headers['Accept-Encoding'] = 'identity\r' ClientServerMatchmaker(self.js_client, "GET %s HTTP/1.0" % url_quote(url), # request headers, '', # content mime="application/x-javascript", ) | 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) sslctx = get_clientctx('localconfig') import OpenSSL.SSL sock = OpenSSL.SSL.Connection(sslctx, sock) addr = (socket.gethostbyname('localhost'), port) sock.set_connect_state() 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: # finished break sock.shutdown() sock.close() | 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.ZeroReturnError: | 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) sslctx = get_clientctx('localconfig') import OpenSSL.SSL sock = OpenSSL.SSL.Connection(sslctx, sock) addr = (socket.gethostbyname('localhost'), port) sock.set_connect_state() 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: # finished break sock.shutdown() sock.close() | 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['sslport'] #print "Get %s from localhost:%d" % (sys.argv[1], sslport) #proxyrequest1(sys.argv[1], sslport) #proxyrequest2(sys.argv[1], sslport) #proxyrequest3(sys.argv[1], sslport) print "Get %s from localhost:%d" % (sys.argv[1], port) proxyrequest4(sys.argv[1], port) | 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['sslport'] #print "Get %s from localhost:%d" % (sys.argv[1], sslport) #proxyrequest1(sys.argv[1], sslport) #proxyrequest2(sys.argv[1], sslport) #proxyrequest3(sys.argv[1], sslport) print "Get %s from localhost:%d" % (sys.argv[1], port) proxyrequest4(sys.argv[1], port) | 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['sslport'] #print "Get %s from localhost:%d" % (sys.argv[1], sslport) #proxyrequest1(sys.argv[1], sslport) #proxyrequest2(sys.argv[1], sslport) #proxyrequest3(sys.argv[1], sslport) print "Get %s from localhost:%d" % (sys.argv[1], port) proxyrequest4(sys.argv[1], port) | 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 = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >> log, _("error fetching %s") % url, msg print >> log, "...", _("done") return chg # remember all local config files filemap = {} for filename in wc.configuration.filterconf_files(wconfig.filterdir): filemap[os.path.basename(filename)] = filename # read md5sums for line in page.read().splitlines(): if "<" in line: print >> log, _("error fetching %s") % url print >> log, "...", _("done") return chg if not line: continue md5sum, filename = line.split() assert filename.endswith('.zap') fullname = os.path.join(wconfig.configdir, filename) # compare checksums if filemap.has_key(filename): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest == md5sum: print >> log, \ _("filter %s not changed, ignoring") % filename continue print >> log, _("updating filter %s") % filename else: print >> log, _("adding new filter %s") % filename # parse new filter url = baseurl+filename page = open_url(url) p = wc.configuration.ZapperParser(fullname, wconfig, compile_data=False) p.parse(fp=page) page.close() if wconfig.merge_folder(p.folder, dryrun=dryrun, log=log): chg = True url = baseurl+"extern-md5sums.txt" try: page = open_url(url) except IOError, msg: print >> log, _("error fetching %s:") % url, msg print >> log, "...", _("done") return chg lines = page.read().splitlines() page.close() for line in lines: if "<" in line: print >> log, _("error fetching %s:") % url, \ _("invalid content") print >> log, "...", _("done") return chg if not line: continue md5sum, filename = line.split() # XXX UNIX-generated md5sum filenames with subdirs are not portable fullname = os.path.join(wconfig.configdir, filename) # compare checksums if os.path.exists(fullname): f = file(fullname) data = f.read() digest = list(md5.new(data).digest()) f.close() digest = "".join([ "%0.2x"%ord(c) for c in digest ]) if digest == md5sum: print >> log, \ _("extern filter %s not changed, ignoring")%filename continue print >> log, _("updating extern filter %s") % filename else: print >> log, _("adding new extern filter %s") % filename chg = True if not dryrun: url = baseurl+filename try: page = open_url(url) except IOError, msg: print >> log, _("error fetching %s:") % url, msg continue data = page.read() if not data: print >> log, _("error fetching %s:") % url, \ _("got no data") continue f = file(fullname, 'wb') f.write(data) f.close() print >> log, "...", _("done") return chg | 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'] is not None: strhosts = self.config['nofilterhosts'] self.config['nofilterhosts'] = ip.strhosts2map(strhosts) else: self.config['nofilterhosts'] = [Set(), []] if self.config['allowedhosts'] is not None: strhosts = self.config['allowedhosts'] self.config['allowedhosts'] = ip.strhosts2map(strhosts) else: self.config['allowedhosts'] = [Set(), []] elif name=='filter': debug(FILTER, "enable filter module %s", attrs['name']) self.config['filters'].append(attrs['name']) | 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'] is not None: strhosts = self.config['nofilterhosts'] self.config['nofilterhosts'] = ip.strhosts2map(strhosts) else: self.config['nofilterhosts'] = [Set(), []] if self.config['allowedhosts'] is not None: strhosts = self.config['allowedhosts'] self.config['allowedhosts'] = ip.strhosts2map(strhosts) else: self.config['allowedhosts'] = [Set(), []] elif name=='filter': debug(FILTER, "enable filter module %s", attrs['name']) self.config['filters'].append(attrs['name']) | 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 pass if not is_public_doc and wc.config["adminuser"]: creds = wc.proxy.auth.get_header_credentials(self.headers, 'Authorization') if not creds: auth = ", ".join(wc.proxy.auth.get_challenges()) self.error(401, wc.i18n._("Authentication Required"), auth=auth) return if 'NTLM' in creds: if creds['NTLM'][0]['type']==wc.proxy.auth.ntlm.NTLMSSP_NEGOTIATE: auth = ",".join(creds['NTLM'][0]) self.error(401, wc.i18n._("Authentication Required"), auth=auth) return # XXX the data=None argument should hold POST data if not wc.proxy.auth.check_credentials(creds, username=wc.config['adminuser'], password_b64=wc.config['adminpass'], uri=wc.proxy.auth.get_auth_uri(self.url), method=self.method, data=None): warn(AUTH, "Bad authentication from %s", self.addr[0]) auth = ", ".join(get_challenges()) self.error(401, wc.i18n._("Authentication Required"), auth=auth) return # get cgi form data form = self.get_form_data() # this object will call server_connected at some point wc.webgui.WebConfig(self, self.url, form, self.protocol, self.headers) | 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 data return f.getoutput() | 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 data return f.getoutput() | 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'] = 0 elif rule.get_name()=='javascript': opts['javascript'] = 1 # generate the HTML filter return {'filter': HtmlFilter(rewrites, url, **opts)} | 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'] = 0 elif rule.get_name()=='javascript': opts['javascript'] = 1 # generate the HTML filter return {'filter': HtmlFilter(rewrites, url, **opts)} | 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() self.waitbuf = [] self.state = 'parse' self.script = '' self.waited = 0 self.rulestack = [] self.buf = [] self.url = url or "unknown" if self.javascript: self.jsEnv = jslib.new_jsenv() self.output_counter = 0 self.popup_counter = 0 | 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() self.waitbuf = [] self.state = 'parse' self.script = '' self.waited = 0 self.rulestack = [] self.buf = [] self.url = url or "unknown" if self.javascript: self.jsEnv = jslib.new_jsenv() self.output_counter = 0 self.popup_counter = 0 | 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() self.waitbuf = [] self.state = 'parse' self.script = '' self.waited = 0 self.rulestack = [] self.buf = [] self.url = url or "unknown" if self.javascript: self.jsEnv = jslib.new_jsenv() self.output_counter = 0 self.popup_counter = 0 | 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", `self.waitbuf`) self._debug(NIGHTMARE, "self.inbuf", `self.inbuf.getvalue()`) self._debug(NIGHTMARE, "self.outbuf", `self.outbuf.getvalue()`) | 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, data) else: self.inbuf.write(data) | 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.