rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.filt("""<script src="
self.filt("""<script src="http://ivwbox.de"></script>""", "")
def testFilter (self): self.filt("""<script src="#ivwbox.de"></script>""", "")
68899b51a56d2ab2230acc59f361f21a6494f2fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/68899b51a56d2ab2230acc59f361f21a6494f2fa/test_rewritescript.py
print "XXX read"
def rawrequest3 (url, port): """raw request with proxy CONNECT protocol""" from wc.proxy.Dispatcher import create_socket from urllib import splitnport parts = urlparse.urlsplit(url) host, sslport = splitnport(parts[1], 443) path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) _sock = create_socket(socket.AF_INET, socket.SOCK_STREAM) addr = (socket.gethostbyname('localhost'), port) _sock.connect(addr) _sock.send('CONNECT %s:%d HTTP/1.1\r\n' % (host, sslport)) _sock.send('User-Agent: getssl\r\n') _sock.send('\r\n') buf = "" while True: buf += _sock.recv(1024) if "\r\n\r\n" in buf: break print repr(buf) print "initiating SSL handshake" sock = socket.ssl(_sock) print "write SSL request...", sock.write("GET %s HTTP/1.1\r\n" % url) sock.write("Host: %s\r\n" % host) sock.write("\r\n") print " ok." while True: try: print "XXX read" print repr(sock.read(80)) except socket.sslerror, msg: print "Oops" break _sock.close()
be161445026098c6100b9ce2201594c86781541a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/be161445026098c6100b9ce2201594c86781541a/getssl.py
print "Oops"
if msg[0] != 6: print "Oops", msg
def rawrequest3 (url, port): """raw request with proxy CONNECT protocol""" from wc.proxy.Dispatcher import create_socket from urllib import splitnport parts = urlparse.urlsplit(url) host, sslport = splitnport(parts[1], 443) path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4])) _sock = create_socket(socket.AF_INET, socket.SOCK_STREAM) addr = (socket.gethostbyname('localhost'), port) _sock.connect(addr) _sock.send('CONNECT %s:%d HTTP/1.1\r\n' % (host, sslport)) _sock.send('User-Agent: getssl\r\n') _sock.send('\r\n') buf = "" while True: buf += _sock.recv(1024) if "\r\n\r\n" in buf: break print repr(buf) print "initiating SSL handshake" sock = socket.ssl(_sock) print "write SSL request...", sock.write("GET %s HTTP/1.1\r\n" % url) sock.write("Host: %s\r\n" % host) sock.write("\r\n") print " ok." while True: try: print "XXX read" print repr(sock.read(80)) except socket.sslerror, msg: print "Oops" break _sock.close()
be161445026098c6100b9ce2201594c86781541a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/be161445026098c6100b9ce2201594c86781541a/getssl.py
ratings.clear()
def _reset_ratings (): ratings.clear() for category, catdata in service['categories'].items(): if catdata['rvalues']: ratings[category] = catdata['rvalues'][0] else: ratings[category] = "" values.clear() for category, value in ratings.items(): if category not in ["generic", "modified"]: values[category] = {value: True} rating_modified.clear()
bfc4984cb80cf8fabc9960826812d18008675f28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bfc4984cb80cf8fabc9960826812d18008675f28/rating_html.py
values.clear() for category, value in ratings.items(): if category not in ["generic", "modified"]: values[category] = {value: True}
values[category] = {} for value in catdata['rvalues']: values[category][value] = False
def _reset_ratings (): ratings.clear() for category, catdata in service['categories'].items(): if catdata['rvalues']: ratings[category] = catdata['rvalues'][0] else: ratings[category] = "" values.clear() for category, value in ratings.items(): if category not in ["generic", "modified"]: values[category] = {value: True} rating_modified.clear()
bfc4984cb80cf8fabc9960826812d18008675f28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bfc4984cb80cf8fabc9960826812d18008675f28/rating_html.py
info = {} error = {} ratings = {} values = {} rating_modified = {}
def _calc_ratings_display (): global ratings_display urls = rating_cache.keys() urls.sort() ratings_display = urls[curindex:curindex+_entries_per_page] for _url in ratings_display: t = _strtime(float(rating_cache[_url]['modified'])) rating_modified[_url] = t.replace(u" ", u"&nbsp;")
bfc4984cb80cf8fabc9960826812d18008675f28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bfc4984cb80cf8fabc9960826812d18008675f28/rating_html.py
info.clear() error.clear()
for key in info.keys(): info[key] = False for key in error.keys(): error[key] = False
def _form_reset (): info.clear() error.clear() _reset_ratings() global url, generic, curindex url = u"" generic = False curindex = 0
bfc4984cb80cf8fabc9960826812d18008675f28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/bfc4984cb80cf8fabc9960826812d18008675f28/rating_html.py
script = escape_js(remove_html_comments(script)) if not jscomments: script = remove_js_comments(script)
script = escape_js(remove_html_comments(script, jscomments=jscomments))
def clean (script, jscomments=True): """ Clean script from comments and HTML. """ script = escape_js(remove_html_comments(script)) if not jscomments: script = remove_js_comments(script) return u"\n<!--\n%s\n//-->\n" % script
1be559507527d8ab8cf4c85c0653082cb57e6e8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1be559507527d8ab8cf4c85c0653082cb57e6e8b/__init__.py
def remove_whitespace (script): lines = [] for line in script.splitlines(): line = line.rstrip() if line: lines.append(line) return "\n".join(lines)
def clean (script, jscomments=True): """ Clean script from comments and HTML. """ script = escape_js(remove_html_comments(script)) if not jscomments: script = remove_js_comments(script) return u"\n<!--\n%s\n//-->\n" % script
1be559507527d8ab8cf4c85c0653082cb57e6e8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1be559507527d8ab8cf4c85c0653082cb57e6e8b/__init__.py
if script[i:i+9].lower() == '</script>' and quote: script = script[:i]+"</scr"+quote+"+"+quote+"ipt>"+\ script[(i+9):]
if script[i:i+9].lower() == '</script>': if quote: script = script[:i] + "</scr" + quote + "+" + \ quote + "ipt>" + script[(i+9):] else: script = script[:i] + script[(i+9):]
def escape_js_line (script): # if we encounter "</script>" in the script, we assume that is # in a quoted string. The solution is to split it into # "</scr"+"ipt>" (with the proper quotes of course) quote = False escape = False i = 0 while i < len(script): c = script[i] if c == '"' or c == "'": if not escape: if quote == c: quote = False elif not quote: quote = c escape = False elif c == '\\': escape = not escape elif c == '<': if script[i:i+9].lower() == '</script>' and quote: script = script[:i]+"</scr"+quote+"+"+quote+"ipt>"+\ script[(i+9):] escape = False else: escape = False i += 1 #script = script.replace('-->', '--&#62;') #script = script_sub("&#60;/script&#62;", script) return script
1be559507527d8ab8cf4c85c0653082cb57e6e8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1be559507527d8ab8cf4c85c0653082cb57e6e8b/__init__.py
def remove_html_comments (script):
def remove_html_comments (script, jscomments=True):
def remove_html_comments (script): """ Remove leading and trailing HTML comments from the script text. """ script = remove_whitespace(script) mo = _start_js_comment(script) if mo: script = script[mo.end():] mo = _end_js_comment(script) if mo: if mo.group("comment") is not None: i = script.rindex("//") else: i = script.rindex("-->") script = script[:i] return script.strip()
1be559507527d8ab8cf4c85c0653082cb57e6e8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1be559507527d8ab8cf4c85c0653082cb57e6e8b/__init__.py
script = remove_whitespace(script)
lines = [] for line in script.splitlines(): line = line.rstrip() if line and (jscomments or not line.lstrip().startswith('//')): lines.append(line) script = "\n".join(lines)
def remove_html_comments (script): """ Remove leading and trailing HTML comments from the script text. """ script = remove_whitespace(script) mo = _start_js_comment(script) if mo: script = script[mo.end():] mo = _end_js_comment(script) if mo: if mo.group("comment") is not None: i = script.rindex("//") else: i = script.rindex("-->") script = script[:i] return script.strip()
1be559507527d8ab8cf4c85c0653082cb57e6e8b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1be559507527d8ab8cf4c85c0653082cb57e6e8b/__init__.py
fp = gzip.GzipFile('', 'rb', 9, StringIO(content))
fp = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(content))
def decode (page): "gunzip or deflate a compressed page" encoding = page.info().get("Content-Encoding") if encoding in ('gzip', 'x-gzip', 'deflate'): # cannot seek in socket descriptors, so must get content now content = page.read() if encoding == 'deflate': fp = StringIO.StringIO(zlib.decompress(content)) else: fp = gzip.GzipFile('', 'rb', 9, StringIO(content)) # remove content-encoding header headers = {} ceheader = re.compile(r"(?i)content-encoding:") for h in page.info().keys(): if not ceheader.match(h): headers[h] = page.info()[h] page = urllib.addinfourl(fp, headers, page.geturl()) return page
1e1981a11cc7b2970c193ace7a39298a83b5598a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1e1981a11cc7b2970c193ace7a39298a83b5598a/update.py
self._debug("JS document.write %s", `data`)
def jsProcessData (self, data): """process data produced by document.write() JavaScript""" #self._debug("JS document.write %s", `data`) self.js_output += 1 # parse recursively self.js_html.feed(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: popup")
def jsProcessPopup (self): """process javascript popup""" #self._debug("JS: popup") self.js_popup += 1
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("buf_append_data")
def buf_append_data (self, data): """we have to make sure that we have no two following DATA things in the tag buffer. Why? To be 100% sure that an ENCLOSED match really matches enclosed data. """ #self._debug("buf_append_data") if data[0]==DATA and self.buf and self.buf[-1][0]==DATA: self.buf[-1][1] += data[1] else: self.buf.append(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("flushbuf")
def flushbuf (self): """clear and return the output buffer""" #self._debug("flushbuf") data = self.outbuf.getvalue() self.outbuf.close() self.outbuf = StringIO() return data
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("self.outbuf %s", `self.outbuf.getvalue()`) self._debug("self.buf %s", `self.buf`) self._debug("self.waitbuf %s", `self.waitbuf`) self._debug("self.inbuf %s", `self.inbuf.getvalue()`)
def _debugbuf (self): """print debugging information about data buffer status""" #self._debug("self.outbuf %s", `self.outbuf.getvalue()`) #self._debug("self.buf %s", `self.buf`) #self._debug("self.waitbuf %s", `self.waitbuf`) #self._debug("self.inbuf %s", `self.inbuf.getvalue()`)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("feed %s", `data`)
def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO() if data: # only feed non-empty data #self._debug("feed %s", `data`) self.parser.feed(data) else: #self._debug("feed") pass else: # wait state ==> put in input buffer #self._debug("wait") self.inbuf.write(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("feed")
def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO() if data: # only feed non-empty data #self._debug("feed %s", `data`) self.parser.feed(data) else: #self._debug("feed") pass else: # wait state ==> put in input buffer #self._debug("wait") self.inbuf.write(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("wait")
def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO() if data: # only feed non-empty data #self._debug("feed %s", `data`) self.parser.feed(data) else: #self._debug("feed") pass else: # wait state ==> put in input buffer #self._debug("wait") self.inbuf.write(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("flush")
def flush (self): #self._debug("flush") # flushing in wait state raises a filter exception if self.state=='wait': raise FilterWait("HtmlParser[%d]: waiting for data"%self.level) self.parser.flush()
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("replay %s", `waitbuf`)
def replay (self, waitbuf): """call the handler functions again with buffer data""" #self._debug("replay %s", `waitbuf`) for item in waitbuf: if item[0]==DATA: self._data(item[1]) elif item[0]==STARTTAG: self.startElement(item[1], item[2]) elif item[0]==ENDTAG: self.endElement(item[1]) elif item[0]==COMMENT: self.comment(item[1])
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("cdata %s", `data`)
def cdata (self, data): """character data""" #self._debug("cdata %s", `data`) return self._data(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("characters %s", `data`)
def characters (self, data): """characters""" #self._debug("characters %s", `data`) return self._data(data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("comment %s", `data`)
def comment (self, data): """a comment; accept only non-empty comments""" #self._debug("comment %s", `data`) item = [COMMENT, data] if self.state=='wait': return self.waitbuf.append(item) if self.comments and data: self.buf.append(item)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("doctype %s", `data`)
def doctype (self, data): #self._debug("doctype %s", `data`) return self._data("<!DOCTYPE%s>"%data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("pi %s", `data`)
def pi (self, data): #self._debug("pi %s", `data`) return self._data("<?%s?>"%data)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("startElement %s", `tag`)
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 %s", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.waitbuf.append(item) rulelist = [] filtered = 0 if tag=="meta" and \ attrs.get('http-equiv', '').lower() =='pics-label': labels = resolve_html_entities(attrs.get('content', '')) # note: if there are no pics rules, this loop is empty for rule in self.pics: msg = check_pics(rule, labels) if msg: raise FilterPics(msg) # first labels match counts self.pics = [] elif tag=="body": # headers finished if self.pics: # no pics data found self.pics = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) debug(FILTER, "using base url %s", `self.base_url`) # look for filter rules which apply for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): #self._debug("matched rule %s on tag %s", `rule.title`, `tag`) if rule.start_sufficient: item = rule.filter_tag(tag, attrs) filtered = "True" if item[0]==STARTTAG and item[1]==tag: foo,tag,attrs = item # give'em a chance to replace more than one attribute continue else: break else: #self._debug("put on buffer") rulelist.append(rule) if rulelist: # remember buffer position for end tag matching pos = len(self.buf) self.rulestack.append((pos, rulelist)) if filtered: self.buf_append_data(item) elif self.js_filter: # if its not yet filtered, try filter javascript self.jsStartElement(tag, attrs) else: self.buf.append(item) # if rule stack is empty, write out the buffered data if not self.rulestack and not self.js_filter: self.buf2data()
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("matched rule %s on tag %s", `rule.title`, `tag`)
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 %s", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.waitbuf.append(item) rulelist = [] filtered = 0 if tag=="meta" and \ attrs.get('http-equiv', '').lower() =='pics-label': labels = resolve_html_entities(attrs.get('content', '')) # note: if there are no pics rules, this loop is empty for rule in self.pics: msg = check_pics(rule, labels) if msg: raise FilterPics(msg) # first labels match counts self.pics = [] elif tag=="body": # headers finished if self.pics: # no pics data found self.pics = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) debug(FILTER, "using base url %s", `self.base_url`) # look for filter rules which apply for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): #self._debug("matched rule %s on tag %s", `rule.title`, `tag`) if rule.start_sufficient: item = rule.filter_tag(tag, attrs) filtered = "True" if item[0]==STARTTAG and item[1]==tag: foo,tag,attrs = item # give'em a chance to replace more than one attribute continue else: break else: #self._debug("put on buffer") rulelist.append(rule) if rulelist: # remember buffer position for end tag matching pos = len(self.buf) self.rulestack.append((pos, rulelist)) if filtered: self.buf_append_data(item) elif self.js_filter: # if its not yet filtered, try filter javascript self.jsStartElement(tag, attrs) else: self.buf.append(item) # if rule stack is empty, write out the buffered data if not self.rulestack and not self.js_filter: self.buf2data()
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("put on buffer")
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 %s", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.waitbuf.append(item) rulelist = [] filtered = 0 if tag=="meta" and \ attrs.get('http-equiv', '').lower() =='pics-label': labels = resolve_html_entities(attrs.get('content', '')) # note: if there are no pics rules, this loop is empty for rule in self.pics: msg = check_pics(rule, labels) if msg: raise FilterPics(msg) # first labels match counts self.pics = [] elif tag=="body": # headers finished if self.pics: # no pics data found self.pics = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) debug(FILTER, "using base url %s", `self.base_url`) # look for filter rules which apply for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): #self._debug("matched rule %s on tag %s", `rule.title`, `tag`) if rule.start_sufficient: item = rule.filter_tag(tag, attrs) filtered = "True" if item[0]==STARTTAG and item[1]==tag: foo,tag,attrs = item # give'em a chance to replace more than one attribute continue else: break else: #self._debug("put on buffer") rulelist.append(rule) if rulelist: # remember buffer position for end tag matching pos = len(self.buf) self.rulestack.append((pos, rulelist)) if filtered: self.buf_append_data(item) elif self.js_filter: # if its not yet filtered, try filter javascript self.jsStartElement(tag, attrs) else: self.buf.append(item) # if rule stack is empty, write out the buffered data if not self.rulestack and not self.js_filter: self.buf2data()
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("endElement %s", `tag`)
def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule.
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: del %s from %s", `name`, `tag`)
def jsStartElement (self, tag, attrs): """Check popups for onmouseout and onmouseover. Inline extern javascript sources""" changed = 0 self.js_src = None self.js_output = 0 self.js_popup = 0 for name in ('onmouseover', 'onmouseout'): if attrs.has_key(name) and self.jsPopup(attrs, name): #self._debug("JS: del %s from %s", `name`, `tag`) 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() url = attrs.get('src', '') scrtype = attrs.get('type', '').lower() is_js = scrtype=='text/javascript' or \ lang.startswith('javascript') or \ not (lang or scrtype) if is_js and url: return self.jsScriptSrc(url, lang) self.buf.append([STARTTAG, tag, attrs])
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: jsPopup")
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" #self._debug("JS: jsPopup") val = resolve_html_entities(attrs[name]) if not val: return self.js_env.attachListener(self) try: self.js_env.executeScriptAsFunction(val, 0.0) except jslib.error, msg: pass self.js_env.detachListener(self) res = self.js_popup self.js_popup = 0 return res
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("jsForm %s action %s %s", `name`, `action`, `target`)
def jsForm (self, name, action, target): """when hitting a (named) form, notify the JS engine about that""" if not name: return #self._debug("jsForm %s action %s %s", `name`, `action`, `target`) self.js_env.addForm(name, action, target)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("switching back to parse with")
def jsScriptData (self, data, url, ver): """Callback for loading <script src=""> data in the background If downloading is finished, data is None""" assert self.state=='wait' if data is None: if not self.js_script: warn(PARSER, "HtmlParser[%d]: empty JS src %s", self.level, url) else: self.buf.append([STARTTAG, "script", {'type': 'text/javascript'}]) script = "\n<!--\n%s\n//-->\n"%escape_js(self.js_script) self.buf.append([DATA, script]) # Note: <script src=""> could be missing an end tag, # but now we need one. Look later for a duplicate </script>. self.buf.append([ENDTAG, "script"]) self.js_script = '' self.state = 'parse' #self._debug("switching back to parse with") self._debugbuf() else: #self._debug("JS read %d <= %s", len(data), url) self.js_script += data
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS read %d <= %s", len(data), url)
def jsScriptData (self, data, url, ver): """Callback for loading <script src=""> data in the background If downloading is finished, data is None""" assert self.state=='wait' if data is None: if not self.js_script: warn(PARSER, "HtmlParser[%d]: empty JS src %s", self.level, url) else: self.buf.append([STARTTAG, "script", {'type': 'text/javascript'}]) script = "\n<!--\n%s\n//-->\n"%escape_js(self.js_script) self.buf.append([DATA, script]) # Note: <script src=""> could be missing an end tag, # but now we need one. Look later for a duplicate </script>. self.buf.append([ENDTAG, "script"]) self.js_script = '' self.state = 'parse' #self._debug("switching back to parse with") self._debugbuf() else: #self._debug("JS read %d <= %s", len(data), url) self.js_script += data
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: jsScript %s %s", ver, `script`)
def jsScript (self, script, ver, item): """execute given script with javascript version ver""" #self._debug("JS: jsScript %s %s", ver, `script`) assert self.state == 'parse' assert len(self.buf) >= 2 self.js_output = 0 self.js_env.attachListener(self) # start recursive html filter (used by jsProcessData) self.js_html = FilterHtmlParser(self.rules, self.pics, self.url, comments=self.comments, javascript=self.js_filter, level=self.level+1) # execute self.js_env.executeScript(unescape_js(script), ver) self.js_env.detachListener(self) # wait for recursive filter to finish self.jsEndScript(item)
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: endScript")
def jsEndScript (self, item): #self._debug("JS: endScript") assert len(self.buf) >= 2 if self.js_output: try: self.js_html.feed('') self.js_html.flush() except FilterWait: self.state = 'wait' self.waited = 'True' make_timer(0.1, lambda : self.jsEndScript(item)) return self.js_html._debugbuf() assert not self.js_html.inbuf.getvalue() assert not self.js_html.waitbuf assert len(self.buf) >= 2 self.buf[-2:-2] = [[DATA, self.js_html.outbuf.getvalue()]]+self.js_html.buf self.js_html = None if (self.js_popup + self.js_output) > 0: # delete old script del self.buf[-1] del self.buf[-1] elif not self.filterEndElement(item[1]): self.buf.append(item) #self._debug("JS: switching back to parse with") self._debugbuf() self.state = 'parse'
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
self._debug("JS: switching back to parse with")
def jsEndScript (self, item): #self._debug("JS: endScript") assert len(self.buf) >= 2 if self.js_output: try: self.js_html.feed('') self.js_html.flush() except FilterWait: self.state = 'wait' self.waited = 'True' make_timer(0.1, lambda : self.jsEndScript(item)) return self.js_html._debugbuf() assert not self.js_html.inbuf.getvalue() assert not self.js_html.waitbuf assert len(self.buf) >= 2 self.buf[-2:-2] = [[DATA, self.js_html.outbuf.getvalue()]]+self.js_html.buf self.js_html = None if (self.js_popup + self.js_output) > 0: # delete old script del self.buf[-1] del self.buf[-1] elif not self.filterEndElement(item[1]): self.buf.append(item) #self._debug("JS: switching back to parse with") self._debugbuf() self.state = 'parse'
b148e442fbaa41c0936bdbd1eac4f2a19641bc8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b148e442fbaa41c0936bdbd1eac4f2a19641bc8c/HtmlParser.py
if data and self.statuscode != 407 and
if data and self.statuscode != 407 and \
def flush (self): """ Flush data of decoders (if any) and filters and write it to the client. return True if flush was successful. """ assert None == wc.log.debug(wc.LOG_PROXY, "%s HttpServer.flush", self) if not self.statuscode and self.method != 'CONNECT': wc.log.warn(wc.LOG_PROXY, "%s flush without status", self) return True data = self.flush_coders(self.decoders) try: for stage in FilterStages: data = wc.filter.applyfilter(stage, data, "finish", self.attrs) except wc.filter.FilterWait, msg: assert None == wc.log.debug(wc.LOG_PROXY, "%s FilterWait %s", self, msg) # the filter still needs some data # to save CPU time make connection unreadable for a while self.set_unreadable(1.0) return False except wc.filter.FilterRating, msg: assert None == wc.log.debug(wc.LOG_PROXY, "%s FilterRating from content %s", self, msg) self._show_rating_deny(str(msg)) return True data = self.flush_coders(self.encoders, data=data) # the client might already have closed if not self.client: return if self.defer_data: self.defer_data = False self.client.server_response(self, self.response, self.statuscode, self.headers) if not self.client: return # note that self.client still could be a ClientServerMatchMaker if data and self.statuscode != 407 and hasattr(self.client, "server_content"): self.client.server_content(data) return True
75f41cf361d7e3c7517d8d880e56290a46c2c12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/75f41cf361d7e3c7517d8d880e56290a46c2c12d/HttpServer.py
def visit_image(self, node):
class FixedHTMLTranslator (html4css1.HTMLTranslator): def visit_image (self, node):
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
Like html4css1.visit_image(), but with align="middle" enforcement.
Like super.visit_image(), but with align="middle" enforcement.
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
atts = node.non_default_attributes() if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')):
atts = {} atts['src'] = node['uri'] if node.has_key('width'): atts['width'] = node['width'] if node.has_key('height'): atts['height'] = node['height'] if node.has_key('scale'): if Image and not (node.has_key('width') and node.has_key('height')):
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
im = html4css1.Image.open(str(atts['src']))
im = Image.open(str(atts['src']))
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
atts['width'] = im.size[0]
atts['width'] = str(im.size[0])
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
atts['height'] = im.size[1]
atts['height'] = str(im.size[1])
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement):
for att_name in 'width', 'height': if atts.has_key(att_name): match = re.match(r'([0-9.]+)(\S*)$', atts[att_name]) assert match atts[att_name] = '%s%s' % ( float(match.group(1)) * (float(node['scale']) / 100), match.group(2)) style = [] for att_name in 'width', 'height': if atts.has_key(att_name): if re.match(r'^[0-9.]+$', atts[att_name]): atts[att_name] += 'px' style.append('%s: %s;' % (att_name, atts[att_name])) del atts[att_name] if style: atts['style'] = ' '.join(style) atts['alt'] = node.get('alt', atts['src']) if (isinstance(node.parent, nodes.TextElement) or (isinstance(node.parent, nodes.reference) and not isinstance(node.parent.parent, nodes.TextElement))): suffix = '' else: suffix = '\n' if node.has_key('align'): if node['align'] == 'center': if suffix: self.body.append('<div align="center" class="align-center">') self.context.append('</div>\n') suffix = '' else: atts['align'] = 'middle' self.context.append('') else: atts['align'] = node['align'] self.context.append('') atts['class'] = 'align-%s' % node['align'] else:
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts)) class HTMLNavTranslator (html4css1.HTMLTranslator):
self.body.append(self.emptytag(node, 'img', suffix, **atts)) class HTMLNavTranslator (FixedHTMLTranslator):
def visit_image(self, node): """ Like html4css1.visit_image(), but with align="middle" enforcement. """ atts = node.non_default_attributes() # The XHTML standard only allows align="middle" if atts.get('align') == u"center": atts['align'] = u"middle" if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if html4css1.Image and not (atts.has_key('width') and atts.has_key('height')): try: im = html4css1.Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: if not atts.has_key('width'): atts['width'] = im.size[0] if not atts.has_key('height'): atts['height'] = im.size[1] del im if atts.has_key('width'): atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if isinstance(node.parent, nodes.TextElement): self.context.append('') else: div_atts = self.image_div_atts(node) self.body.append(self.starttag({}, 'div', '', **div_atts)) self.context.append('</div>\n') self.body.append(self.emptytag(node, 'img', '', **atts))
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
<![CDATA[
<!--
def get_topframe_bashing (self): return """<script type="text/javascript">
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
]]>
// -->
def get_topframe_bashing (self): return """<script type="text/javascript">
a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a91ca12aa92c8a8835925bc93e88d41f8ad7b3b4/htmlnav.py
p.feed("<hTml>")
def _test(): p = HtmlPrinter() p.feed("<hTml>") p.feed("<a href>") p.feed("<a href=''>") p.feed('<a href="">') p.feed("<a href='a'>") p.feed('<a href="a">') p.feed("<a href=a>") p.feed("<a href='\"'>") p.feed("<a href=\"'\">") p.feed("<a href=' '>") p.feed("<a href=a href=b>") p.feed("<a/>") p.feed("<a href/>") p.feed("<a href=a />") p.feed("</a>") p.feed("<?bla foo?>") p.feed("<?bla?>") p.feed("<!-- - comment -->") p.feed("<!---->") p.feed("<!DOCTYPE \"vla foo>") p.flush()
565cd78c4edea6916e60976b5fa0570f88e50d95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/565cd78c4edea6916e60976b5fa0570f88e50d95/htmllib.py
p.feed("<a href=''>") p.feed('<a href="">') p.feed("<a href='a'>") p.feed('<a href="a">')
def _test(): p = HtmlPrinter() p.feed("<hTml>") p.feed("<a href>") p.feed("<a href=''>") p.feed('<a href="">') p.feed("<a href='a'>") p.feed('<a href="a">') p.feed("<a href=a>") p.feed("<a href='\"'>") p.feed("<a href=\"'\">") p.feed("<a href=' '>") p.feed("<a href=a href=b>") p.feed("<a/>") p.feed("<a href/>") p.feed("<a href=a />") p.feed("</a>") p.feed("<?bla foo?>") p.feed("<?bla?>") p.feed("<!-- - comment -->") p.feed("<!---->") p.feed("<!DOCTYPE \"vla foo>") p.flush()
565cd78c4edea6916e60976b5fa0570f88e50d95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/565cd78c4edea6916e60976b5fa0570f88e50d95/htmllib.py
p.feed("<a href='\"'>") p.feed("<a href=\"'\">") p.feed("<a href=' '>") p.feed("<a href=a href=b>") p.feed("<a/>") p.feed("<a href/>") p.feed("<a href=a />") p.feed("</a>") p.feed("<?bla foo?>") p.feed("<?bla?>") p.feed("<!-- - comment -->") p.feed("<!---->") p.feed("<!DOCTYPE \"vla foo>")
def _test(): p = HtmlPrinter() p.feed("<hTml>") p.feed("<a href>") p.feed("<a href=''>") p.feed('<a href="">') p.feed("<a href='a'>") p.feed('<a href="a">') p.feed("<a href=a>") p.feed("<a href='\"'>") p.feed("<a href=\"'\">") p.feed("<a href=' '>") p.feed("<a href=a href=b>") p.feed("<a/>") p.feed("<a href/>") p.feed("<a href=a />") p.feed("</a>") p.feed("<?bla foo?>") p.feed("<?bla?>") p.feed("<!-- - comment -->") p.feed("<!---->") p.feed("<!DOCTYPE \"vla foo>") p.flush()
565cd78c4edea6916e60976b5fa0570f88e50d95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/565cd78c4edea6916e60976b5fa0570f88e50d95/htmllib.py
p.feed(""" """)
p.feed("")
def _broken (): p = HtmlPrinter() p.feed(""" """) p.flush()
565cd78c4edea6916e60976b5fa0570f88e50d95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/565cd78c4edea6916e60976b5fa0570f88e50d95/htmllib.py
_broken()
_test()
def _broken (): p = HtmlPrinter() p.feed(""" """) p.flush()
565cd78c4edea6916e60976b5fa0570f88e50d95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/565cd78c4edea6916e60976b5fa0570f88e50d95/htmllib.py
for c in '<!-- -->':
for c in '<a/>':
def _broken (): p = HtmlPrinter() for c in '<!-- -->': p.feed(c) p.flush()
64df81f24d6581935cd1910a3222681bcace5239 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/64df81f24d6581935cd1910a3222681bcace5239/htmllib.py
debug(BRING_IT_ON, "removing header", `h`)
def remove_headers (headers, to_remove): """utility function to remove entries from RFC822 headers""" for h in to_remove: if headers.has_key(h): debug(BRING_IT_ON, "removing header", `h`) del headers[h]
b27269ed91b8e4886956108de4904f792a4ff62a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b27269ed91b8e4886956108de4904f792a4ff62a/__init__.py
HtmlParser.feed(self, data)
self.parser.feed(data)
def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something 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: # only feed non-empty data #self._debug(NIGHTMARE, "feed", `data`) HtmlParser.feed(self, data) else: #self._debug(NIGHTMARE, "feed") pass else: # wait state --> put in input buffer #self._debug(NIGHTMARE, "wait") self.inbuf.write(data)
d7fc78754f8d18fb4cb238f57002ba5d078f0dc8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d7fc78754f8d18fb4cb238f57002ba5d078f0dc8/Rewriter.py
HtmlParser.flush(self)
self.parser.flush()
def flush (self): #self._debug(HURT_ME_PLENTY, "flush") # flushing in wait state raises a filter exception if self.state=='wait': raise FilterException("HtmlFilter[%d]: still waiting for data"%self.level) HtmlParser.flush(self)
d7fc78754f8d18fb4cb238f57002ba5d078f0dc8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d7fc78754f8d18fb4cb238f57002ba5d078f0dc8/Rewriter.py
wc.set_debuglevel(wc.HURT_ME_PLENTY)
wc.set_debuglevel(wc.NIGHTMARE)
def _main(): fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) import wc, time wc.config = wc.Configuration() # set debug level wc.set_debuglevel(wc.HURT_ME_PLENTY) wc.config['filters'] = ['Replacer', 'Rewriter', 'BinaryCharFilter'] wc.config.init_filter_modules() from wc.proxy import proxy_poll, run_timers from wc.filter import FilterException attrs = wc.filter.initStateObjects(url=fname) filtered = "" data = f.read(1024) while data: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs) except FilterException, msg: pass data = f.read(1024) i = 1 while 1: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, "", 'finish', attrs) break except FilterException, msg: print "Test: finish: exception:", msg proxy_poll(timeout=max(0, run_timers())) i+=1 if i==99: print "Test: oooooops" break print filtered
595daecc5983d5fcc29db04a559a669a213d19b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/595daecc5983d5fcc29db04a559a669a213d19b9/filterfile.py
filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs)
filtered += wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs)
def _main(): fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) import wc, time wc.config = wc.Configuration() # set debug level wc.set_debuglevel(wc.HURT_ME_PLENTY) wc.config['filters'] = ['Replacer', 'Rewriter', 'BinaryCharFilter'] wc.config.init_filter_modules() from wc.proxy import proxy_poll, run_timers from wc.filter import FilterException attrs = wc.filter.initStateObjects(url=fname) filtered = "" data = f.read(1024) while data: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs) except FilterException, msg: pass data = f.read(1024) i = 1 while 1: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, "", 'finish', attrs) break except FilterException, msg: print "Test: finish: exception:", msg proxy_poll(timeout=max(0, run_timers())) i+=1 if i==99: print "Test: oooooops" break print filtered
595daecc5983d5fcc29db04a559a669a213d19b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/595daecc5983d5fcc29db04a559a669a213d19b9/filterfile.py
filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY,
filtered += wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY,
def _main(): fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) import wc, time wc.config = wc.Configuration() # set debug level wc.set_debuglevel(wc.HURT_ME_PLENTY) wc.config['filters'] = ['Replacer', 'Rewriter', 'BinaryCharFilter'] wc.config.init_filter_modules() from wc.proxy import proxy_poll, run_timers from wc.filter import FilterException attrs = wc.filter.initStateObjects(url=fname) filtered = "" data = f.read(1024) while data: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs) except FilterException, msg: pass data = f.read(1024) i = 1 while 1: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, "", 'finish', attrs) break except FilterException, msg: print "Test: finish: exception:", msg proxy_poll(timeout=max(0, run_timers())) i+=1 if i==99: print "Test: oooooops" break print filtered
595daecc5983d5fcc29db04a559a669a213d19b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/595daecc5983d5fcc29db04a559a669a213d19b9/filterfile.py
print "Test: finish: exception:", msg
print >>sys.stderr, "Test: finish: exception:", msg
def _main(): fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) import wc, time wc.config = wc.Configuration() # set debug level wc.set_debuglevel(wc.HURT_ME_PLENTY) wc.config['filters'] = ['Replacer', 'Rewriter', 'BinaryCharFilter'] wc.config.init_filter_modules() from wc.proxy import proxy_poll, run_timers from wc.filter import FilterException attrs = wc.filter.initStateObjects(url=fname) filtered = "" data = f.read(1024) while data: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, data, 'filter', attrs) except FilterException, msg: pass data = f.read(1024) i = 1 while 1: try: filtered = wc.filter.applyfilter(wc.filter.FILTER_RESPONSE_MODIFY, "", 'finish', attrs) break except FilterException, msg: print "Test: finish: exception:", msg proxy_poll(timeout=max(0, run_timers())) i+=1 if i==99: print "Test: oooooops" break print filtered
595daecc5983d5fcc29db04a559a669a213d19b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/595daecc5983d5fcc29db04a559a669a213d19b9/filterfile.py
if server.headers.has_key('Transfer-Encoding'): to_remove.add('Transfer-Encoding') tencs = server.headers['Transfer-Encoding'].lower() for tenc in tencs.split(","): tenc = tenc.strip() if ";" in tenc: tenc = tenc.split(";", 1)[0] if not tenc or tenc == 'identity': continue if tenc == 'chunked': server.decoders.append(UnchunkStream.UnchunkStream(server)) elif tenc in ('x-gzip', 'gzip'): server.decoders.append(GunzipStream.GunzipStream(server)) elif tenc == 'deflate': server.decoders.append(DeflateStream.DeflateStream(server)) else: wc.log.warn(wc.LOG_PROXY, "unsupported transfer encoding in %r", tencs) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'Transfer-Encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
if server.headers.has_key('Transfer-Encoding'): tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server))
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r'
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
encoding = server.headers.get('Content-Encoding', '').lower() if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) to_remove = ['Content-Encoding']
if server.headers.has_key('Content-Encoding'): to_remove.add('Content-Encoding') cencs = server.headers['Content-Encoding'].lower() for cenc in cencs.split(","): cenc = cenc.strip() if ";" in cenc: cenc = cenc.split(";", 1)[0] if not cenc or cenc == 'identity': continue if filename is not None and \ (filename.endswith(".gz") or filename.endswith(".tgz")): continue if cenc in ('gzip', 'x-gzip'): server.decoders.append(GunzipStream.GunzipStream()) elif cenc == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: wc.log.warn(wc.LOG_PROXY, "unsupported content encoding in %r", encoding)
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
to_remove.append('Cache-Control') remove_headers(server.headers, to_remove)
to_remove.add('Cache-Control')
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r'
remove_headers(server.headers, to_remove)
def server_set_encoding_headers (server, filename=None): """ Set encoding headers. """ rewrite = server.is_rewrite() bytes_remaining = get_content_length(server.headers) to_remove = sets.Set() # remove content length if rewrite: to_remove.add('Content-Length') # add decoders if server.headers.has_key('Transfer-Encoding'): # chunked encoded tenc = server.headers['Transfer-Encoding'] if tenc != 'chunked': wc.log.warn(wc.LOG_PROXY, "unknown transfer encoding %r, assuming chunked encoding", tenc) server.decoders.append(UnchunkStream.UnchunkStream(server)) server.encoders.append(ChunkStream.ChunkStream(server)) if server.headers.has_key("Content-Length"): wc.log.warn(wc.LOG_PROXY, 'chunked encoding should not have Content-Length') to_remove.add("Content-Length") bytes_remaining = None elif rewrite: # To make pipelining possible, enable chunked encoding. server.headers['Transfer-Encoding'] = "chunked\r" if server.headers.has_key("Content-Length"): to_remove.add("Content-Length") server.encoders.append(ChunkStream.ChunkStream(server)) remove_headers(server.headers, to_remove) # only decompress on rewrite if not rewrite: return bytes_remaining # Compressed content (uncompress only for rewriting modules) encoding = server.headers.get('Content-Encoding', '').lower() # note: do not gunzip .gz files if encoding in ('gzip', 'x-gzip', 'deflate') and \ (filename is None or not filename.endswith(".gz")): if encoding == 'deflate': server.decoders.append(DeflateStream.DeflateStream()) else: server.decoders.append(GunzipStream.GunzipStream()) # remove encoding because we unzip the stream to_remove = ['Content-Encoding'] # remove no-transform cache control if server.headers.get('Cache-Control', '').lower() == 'no-transform': to_remove.append('Cache-Control') remove_headers(server.headers, to_remove) # add warning server.headers['Warning'] = "214 Transformation applied\r" elif encoding and encoding!='identity': wc.log.warn(wc.LOG_PROXY, _("unsupported encoding: %r"), encoding) # do not disable filtering for unknown content-encodings # this could result in a DoS attack (server sending garbage # as content-encoding) if not server.headers.has_key('Content-Length'): server.headers['Connection'] = 'close\r' return bytes_remaining
1d0b4dde3d21f983a9244c939ccb80fd5778999a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/1d0b4dde3d21f983a9244c939ccb80fd5778999a/Headers.py
hostset.add(expand_ip(host))
hostset.add(expand_ip(host)[0])
def hosts2map (hosts): """return a set of named hosts, and a list of subnets (host/netmask adresses). Only IPv4 host/netmasks are supported. """ hostset = Set() nets = [] for host in hosts: if _host_bitmask_re.match(host): host, mask = host.split("/") mask = int(mask) if not is_valid_bitmask(mask): error(PROXY, "bitmask %d is not a valid network mask", mask) continue if not is_valid_ipv4(host): error(PROXY, "host %s is not a valid ip address", host) continue nets.append(dq2net(host, suffix2mask(mask))) elif _host_netmask_re.match(host): host, mask = host.split("/") if not is_valid_ipv4(host): error(PROXY, "host %s is not a valid ip address", host) continue if not is_valid_ipv4(mask): error(PROXY, "mask %s is not a valid ip network mask", mask) continue nets.append(dq2net(host, dq2mask(mask))) elif is_valid_ip(host): hostset.add(expand_ip(host)) else: try: ips = resolve_host(host) for i in ips: hostset.add(i) except socket.gaierror: pass return (hostset, nets)
e5f55f265db01ddd479e1a95dc970fd6b78a7549 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/e5f55f265db01ddd479e1a95dc970fd6b78a7549/ip.py
ips = resolve_host(host) for i in ips: hostset.add(i)
hostset |= resolve_host(host)
def hosts2map (hosts): """return a set of named hosts, and a list of subnets (host/netmask adresses). Only IPv4 host/netmasks are supported. """ hostset = Set() nets = [] for host in hosts: if _host_bitmask_re.match(host): host, mask = host.split("/") mask = int(mask) if not is_valid_bitmask(mask): error(PROXY, "bitmask %d is not a valid network mask", mask) continue if not is_valid_ipv4(host): error(PROXY, "host %s is not a valid ip address", host) continue nets.append(dq2net(host, suffix2mask(mask))) elif _host_netmask_re.match(host): host, mask = host.split("/") if not is_valid_ipv4(host): error(PROXY, "host %s is not a valid ip address", host) continue if not is_valid_ipv4(mask): error(PROXY, "mask %s is not a valid ip network mask", mask) continue nets.append(dq2net(host, dq2mask(mask))) elif is_valid_ip(host): hostset.add(expand_ip(host)) else: try: ips = resolve_host(host) for i in ips: hostset.add(i) except socket.gaierror: pass return (hostset, nets)
e5f55f265db01ddd479e1a95dc970fd6b78a7549 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/e5f55f265db01ddd479e1a95dc970fd6b78a7549/ip.py
item = form[key] if isinstance(item, list): item = item[0] elif hasattr(item, "value"): item = item.value return item.decode(charset)
return get_item_value(form[key])
def getval (form, key): """return a formfield value""" if not form.has_key(key): return u'' item = form[key] if isinstance(item, list): item = item[0] elif hasattr(item, "value"): item = item.value return item.decode(charset)
ebb3f0f8f26d57ebcf5818dbfd680ba9192a5d5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ebb3f0f8f26d57ebcf5818dbfd680ba9192a5d5f/__init__.py
item = form[key] if isinstance(item, list): l = [x.value for x in item] elif hasattr(item, "value"): l = [item.value] else: l = [item] return [ x.decode(charset) for x in l ]
return get_item_list(form[key]) def get_prefix_vals (form, prefix): """return a list of (key, value) pairs where ``prefix+key'' is a valid form field""" res = [] for key, item in form.items(): if key.startswith(prefix): res.append(key[len(prefix):], get_item_value(item)) return res
def getlist (form, key): """return a list of formfield values""" if not form.has_key(key): return [] item = form[key] if isinstance(item, list): l = [x.value for x in item] elif hasattr(item, "value"): l = [item.value] else: l = [item] return [ x.decode(charset) for x in l ]
ebb3f0f8f26d57ebcf5818dbfd680ba9192a5d5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ebb3f0f8f26d57ebcf5818dbfd680ba9192a5d5f/__init__.py
if ct != self.mime:
if ct is None:
def check_headers (self): """add missing content-type and/or encoding headers""" # 304 Not Modified does not send any type or encoding info, # because this info was cached if self.statuscode == '304': return # check content-type against our own guess i = self.document.find('?') if i>0: document = self.document[:i] else: document = self.document gm = mimetypes.guess_type(document, None) ct = self.headers.get('Content-Type', None) if self.mime: if ct != self.mime: warn(PROXY, i18n._("set Content-Type from %s to %s in %s"), `str(ct)`, `self.mime`, `self.url`) self.headers['Content-Type'] = "%s\r"%self.mime elif gm[0]: # guessed an own content type if ct is None: warn(PROXY, i18n._("add Content-Type %s to %s"), `gm[0]`, `self.url`) self.headers['Content-Type'] = "%s\r"%gm[0] # fix some content types elif not ct.startswith(gm[0]) and \ gm[0] in _fix_content_types: warn(PROXY, i18n._("change Content-Type from %s to %s in %s"), `ct`, `gm[0]`, `self.url`) self.headers['Content-Type'] = "%s\r"%gm[0] if gm[1] and gm[1] in _fix_content_encodings: ce = self.headers.get('Content-Encoding', None) # guessed an own encoding type if ce is None: self.headers['Content-Encoding'] = "%s\r"%gm[1] warn(PROXY, i18n._("add Content-Encoding %s to %s"), `gm[1]`, `self.url`) elif ce != gm[1]: warn(PROXY, i18n._("change Content-Encoding from %s to %s in %s"), `ce`, `gm[1]`, `self.url`) self.headers['Content-Encoding'] = "%s\r"%gm[1] # hmm, fix application/x-httpd-php* if self.headers.get('Content-Type', '').lower().startswith('application/x-httpd-php'): warn(PROXY, i18n._("fix x-httpd-php Content-Type")) self.headers['Content-Type'] = 'text/html\r'
cfd97cb940d0a998442a77b2135d577375a80494 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/cfd97cb940d0a998442a77b2135d577375a80494/HttpServer.py
self.js_filter = opts['javascript'] and jslib
self.javascript = opts['javascript'] and jslib
def __init__ (self, opts): self.js_filter = opts['javascript'] and jslib self.js_html = None self.js_src = False self.js_script = '' if self.js_filter: self.js_env = jslib.new_jsenv() self.js_output = 0 self.js_popup = 0
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
if self.js_filter:
if self.javascript:
def __init__ (self, opts): self.js_filter = opts['javascript'] and jslib self.js_html = None self.js_src = False self.js_script = '' if self.js_filter: self.js_env = jslib.new_jsenv() self.js_output = 0 self.js_popup = 0
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
error(FILTER, "waited too long for %s"%self.state[1]) self.js_client.finish() self.js_html = None
def flush (self): self._debug("flush") if self.waited > 100: # waited too long; stop js background downloader and # switch back to parse error(FILTER, "waited too long for %s"%self.state[1]) if self.js_env.hasListener(self): self.js_env.detachListener(self) self.js_html = None self.state = ('parse',) self.feed("") # will replay() buffered data elif self.state[0]=='wait': # flushing in wait state raises a filter exception self.waited += 1 raise FilterWait("HtmlParser[%d,wait]: waited %d times for %s"%\ (self.level, self.waited, self.state[1])) self.parser.flush()
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
error(FILTER, "waited too long for %s"%self.state[1]) if self.js_env.hasListener(self): self.js_env.detachListener(self) self.js_html = None
def flush (self): self._debug("flush") if self.waited > 100: # waited too long; stop js background downloader and # switch back to parse error(FILTER, "waited too long for %s"%self.state[1]) if self.js_env.hasListener(self): self.js_env.detachListener(self) self.js_html = None self.state = ('parse',) self.feed("") # will replay() buffered data elif self.state[0]=='wait': # flushing in wait state raises a filter exception self.waited += 1 raise FilterWait("HtmlParser[%d,wait]: waited %d times for %s"%\ (self.level, self.waited, self.state[1])) self.parser.flush()
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
self.feed("")
self.feed("")
def flush (self): self._debug("flush") if self.waited > 100: # waited too long; stop js background downloader and # switch back to parse error(FILTER, "waited too long for %s"%self.state[1]) if self.js_env.hasListener(self): self.js_env.detachListener(self) self.js_html = None self.state = ('parse',) self.feed("") # will replay() buffered data elif self.state[0]=='wait': # flushing in wait state raises a filter exception self.waited += 1 raise FilterWait("HtmlParser[%d,wait]: waited %d times for %s"%\ (self.level, self.waited, self.state[1])) self.parser.flush()
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
elif self.js_filter:
elif self.javascript:
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 %s", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state[0]=='wait': self.waitbuf.append(item) return rulelist = [] filtered = False if tag=="meta" and \ attrs.get('http-equiv', '').lower() =='pics-label': labels = resolve_html_entities(attrs.get('content', '')) # note: if there are no pics rules, this loop is empty for rule in self.pics: msg = check_pics(rule, labels) if msg: raise FilterPics(msg) # first labels match counts self.pics = [] elif tag=="body": # headers finished if self.pics: # no pics data found self.pics = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) self._debug("using base url %s", `self.base_url`) # search for and prevent known security flaws in HTML self.security.scan_start_tag(tag, attrs, self)
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
if not self.rulestack and not self.js_filter:
if not self.rulestack and not self.javascript:
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 %s", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state[0]=='wait': self.waitbuf.append(item) return rulelist = [] filtered = False if tag=="meta" and \ attrs.get('http-equiv', '').lower() =='pics-label': labels = resolve_html_entities(attrs.get('content', '')) # note: if there are no pics rules, this loop is empty for rule in self.pics: msg = check_pics(rule, labels) if msg: raise FilterPics(msg) # first labels match counts self.pics = [] elif tag=="body": # headers finished if self.pics: # no pics data found self.pics = [] elif tag=="base" and attrs.has_key('href'): self.base_url = strip_quotes(attrs['href']) self._debug("using base url %s", `self.base_url`) # search for and prevent known security flaws in HTML self.security.scan_start_tag(tag, attrs, self)
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
if self.js_filter and tag=='script':
if self.javascript and tag=='script':
def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule.
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
client = HttpProxyClient(self.jsScriptData, (url, ver)) ClientServerMatchmaker(client, "GET %s HTTP/1.1" % url, WcMessage(StringIO('')), '',
self.js_client = HttpProxyClient(self.jsScriptData, (url, ver)) ClientServerMatchmaker(self.js_client, "GET %s HTTP/1.1" % url, WcMessage(StringIO('')), '',
def jsScriptSrc (self, url, language): """Start a background download for <script src=""> tags""" assert self.state[0]=='parse', "non-parse state %s" % str(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) url = norm_url(url) if _has_ws(url): warn(PARSER, "HtmlParser[%d]: broken JS url %s at %s", self.level, `url`, `self.url`) return self.state = ('wait', url) self.waited = 1 self.js_src = True client = HttpProxyClient(self.jsScriptData, (url, ver)) ClientServerMatchmaker(client, "GET %s HTTP/1.1" % url, #request WcMessage(StringIO('')), #headers '', #content {'nofilter': None}, # nofilter 'identity', # compress mime = "application/x-javascript", )
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
comments=self.comments, javascript=self.js_filter, level=self.level+1)
comments=self.comments, javascript=self.javascript, level=self.level+1)
def jsScript (self, script, ver, item): """execute given script with javascript version ver""" self._debug("JS: jsScript %s %s", ver, `script`) assert self.state[0]=='parse', "non-parse state %s" % str(self.state) assert len(self.buf) >= 2, "too small buffer %s" % str(self.buf) self.js_output = 0 self.js_env.attachListener(self) # start recursive html filter (used by jsProcessData) self.js_html = FilterHtmlParser(self.rules, self.pics, self.url, comments=self.comments, javascript=self.js_filter, level=self.level+1) # execute self.js_env.executeScript(unescape_js(script), ver) self.js_env.detachListener(self) # wait for recursive filter to finish self.jsEndScript(item)
9d308cf36c9925fe55e611168b12175184ce8c08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9d308cf36c9925fe55e611168b12175184ce8c08/HtmlParser.py
from urllib import splittype, splithost, splitport
from urllib import splittype, splithost, splitnport
def fileno(self): return self.socket.fileno()
8b9d971b788b3e4589331da9aac5312e6ac40978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8b9d971b788b3e4589331da9aac5312e6ac40978/__init__.py
if not host: hostname = "localhost" port = config['port'] else: hostname, port = splitport(host) if port is None: port = 80 else: port = int(port) return scheme, hostname.lower(), port, document
port = 80 if host: host = host.lower() host, port = splitnport(host, 80) return scheme, host, port, document
def spliturl (url): """split url in a tuple (scheme, hostname, port, document) where hostname is always lowercased""" # XXX this relies on scheme==http! scheme, netloc = splittype(url) host, document = splithost(netloc) if not host: hostname = "localhost" port = config['port'] else: hostname, port = splitport(host) if port is None: port = 80 else: port = int(port) return scheme, hostname.lower(), port, document
8b9d971b788b3e4589331da9aac5312e6ac40978 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8b9d971b788b3e4589331da9aac5312e6ac40978/__init__.py
info.append("Rule removed")
info.append(i18n._("Rule removed"))
def _form_removerule (rule): curfolder.rules.remove(rule) global currule currule = None info.append("Rule removed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Attribute added")
info.append(i18n._("Rewrite attribute added"))
def _form_rewrite_addattr (form): name = getval(form, "attrname").strip() if not name: error.append(i18n._("Empty attribute name")) return value = getval(form, "attrval") currule.attrs[name] = value info.append("Attribute added")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Attributes removed")
info.append(i18n._("Rewrite attributes removed"))
def _form_rewrite_removeattrs (form): toremove = getlist(form, 'delattr') if toremove: for attr in toremove: del currule.attrs[attr] info.append("Attributes removed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
error.append("Empty rule title")
error.append(i18n._("Empty rule title"))
def _form_rule_titledesc (form): title = getval(form, 'rule_title') if not title: error.append("Empty rule title") return if title!=currule.title: currule.title = title info.append("Rule title changed") desc = getval(form, 'rule_description') if desc!=currule.desc: currule.desc = desc info.append("Rule description changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule title changed")
info.append(i18n._("Rule title changed"))
def _form_rule_titledesc (form): title = getval(form, 'rule_title') if not title: error.append("Empty rule title") return if title!=currule.title: currule.title = title info.append("Rule title changed") desc = getval(form, 'rule_description') if desc!=currule.desc: currule.desc = desc info.append("Rule description changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule description changed")
info.append(i18n._("Rule description changed"))
def _form_rule_titledesc (form): title = getval(form, 'rule_title') if not title: error.append("Empty rule title") return if title!=currule.title: currule.title = title info.append("Rule title changed") desc = getval(form, 'rule_description') if desc!=currule.desc: currule.desc = desc info.append("Rule description changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule match url changed")
info.append(i18n._("Rule match url changed"))
def _form_rule_matchurl (form): matchurl = getval(form, 'rule_matchurl').strip() if matchurl!=currule.matchurl: currule.matchurl = matchurl info.append("Rule match url changed") dontmatchurl = getval(form, 'rule_dontmatchurl').strip() if dontmatchurl!=currule.dontmatchurl: currule.dontmatchurl = dontmatchurl info.append("Rule dontmatch url changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule dontmatch url changed")
info.append(i18n._("Rule dontmatch url changed"))
def _form_rule_matchurl (form): matchurl = getval(form, 'rule_matchurl').strip() if matchurl!=currule.matchurl: currule.matchurl = matchurl info.append("Rule match url changed") dontmatchurl = getval(form, 'rule_dontmatchurl').strip() if dontmatchurl!=currule.dontmatchurl: currule.dontmatchurl = dontmatchurl info.append("Rule dontmatch url changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule url scheme changed")
info.append(i18n._("Rule url scheme changed"))
def _form_rule_urlparts (form): scheme = getval(form, 'rule_urlscheme').strip() if scheme!=currule.scheme: currule.scheme = scheme info.append("Rule url scheme changed") host = getval(form, 'rule_urlhost').strip() if host!=currule.host: currule.host = host info.append("Rule url host changed") port = getval(form, 'rule_urlport').strip() if port!=currule.port: currule.port = port info.append("Rule url port changed") path = getval(form, 'rule_urlpath').strip() if path!=currule.path: currule.path = path info.append("Rule url path changed") parameters = getval(form, 'rule_urlparameters').strip() if parameters!=currule.parameters: currule.parameters = parameters info.append("Rule url parameters changed") query = getval(form, 'rule_urlquery').strip() if query!=currule.query: currule.query = query info.append("Rule url query changed") fragment = getval(form, 'rule_urlfragment').strip() if fragment!=currule.fragment: currule.fragment = fragment info.append("Rule url fragment changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule url host changed")
info.append(i18n._("Rule url host changed"))
def _form_rule_urlparts (form): scheme = getval(form, 'rule_urlscheme').strip() if scheme!=currule.scheme: currule.scheme = scheme info.append("Rule url scheme changed") host = getval(form, 'rule_urlhost').strip() if host!=currule.host: currule.host = host info.append("Rule url host changed") port = getval(form, 'rule_urlport').strip() if port!=currule.port: currule.port = port info.append("Rule url port changed") path = getval(form, 'rule_urlpath').strip() if path!=currule.path: currule.path = path info.append("Rule url path changed") parameters = getval(form, 'rule_urlparameters').strip() if parameters!=currule.parameters: currule.parameters = parameters info.append("Rule url parameters changed") query = getval(form, 'rule_urlquery').strip() if query!=currule.query: currule.query = query info.append("Rule url query changed") fragment = getval(form, 'rule_urlfragment').strip() if fragment!=currule.fragment: currule.fragment = fragment info.append("Rule url fragment changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule url port changed")
info.append(i18n._("Rule url port changed"))
def _form_rule_urlparts (form): scheme = getval(form, 'rule_urlscheme').strip() if scheme!=currule.scheme: currule.scheme = scheme info.append("Rule url scheme changed") host = getval(form, 'rule_urlhost').strip() if host!=currule.host: currule.host = host info.append("Rule url host changed") port = getval(form, 'rule_urlport').strip() if port!=currule.port: currule.port = port info.append("Rule url port changed") path = getval(form, 'rule_urlpath').strip() if path!=currule.path: currule.path = path info.append("Rule url path changed") parameters = getval(form, 'rule_urlparameters').strip() if parameters!=currule.parameters: currule.parameters = parameters info.append("Rule url parameters changed") query = getval(form, 'rule_urlquery').strip() if query!=currule.query: currule.query = query info.append("Rule url query changed") fragment = getval(form, 'rule_urlfragment').strip() if fragment!=currule.fragment: currule.fragment = fragment info.append("Rule url fragment changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule url path changed")
info.append(i18n._("Rule url path changed"))
def _form_rule_urlparts (form): scheme = getval(form, 'rule_urlscheme').strip() if scheme!=currule.scheme: currule.scheme = scheme info.append("Rule url scheme changed") host = getval(form, 'rule_urlhost').strip() if host!=currule.host: currule.host = host info.append("Rule url host changed") port = getval(form, 'rule_urlport').strip() if port!=currule.port: currule.port = port info.append("Rule url port changed") path = getval(form, 'rule_urlpath').strip() if path!=currule.path: currule.path = path info.append("Rule url path changed") parameters = getval(form, 'rule_urlparameters').strip() if parameters!=currule.parameters: currule.parameters = parameters info.append("Rule url parameters changed") query = getval(form, 'rule_urlquery').strip() if query!=currule.query: currule.query = query info.append("Rule url query changed") fragment = getval(form, 'rule_urlfragment').strip() if fragment!=currule.fragment: currule.fragment = fragment info.append("Rule url fragment changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py
info.append("Rule url parameters changed")
info.append(i18n._("Rule url parameters changed"))
def _form_rule_urlparts (form): scheme = getval(form, 'rule_urlscheme').strip() if scheme!=currule.scheme: currule.scheme = scheme info.append("Rule url scheme changed") host = getval(form, 'rule_urlhost').strip() if host!=currule.host: currule.host = host info.append("Rule url host changed") port = getval(form, 'rule_urlport').strip() if port!=currule.port: currule.port = port info.append("Rule url port changed") path = getval(form, 'rule_urlpath').strip() if path!=currule.path: currule.path = path info.append("Rule url path changed") parameters = getval(form, 'rule_urlparameters').strip() if parameters!=currule.parameters: currule.parameters = parameters info.append("Rule url parameters changed") query = getval(form, 'rule_urlquery').strip() if query!=currule.query: currule.query = query info.append("Rule url query changed") fragment = getval(form, 'rule_urlfragment').strip() if fragment!=currule.fragment: currule.fragment = fragment info.append("Rule url fragment changed")
9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9ad2312d756ee18c5d8cc9bb1f58ad01a1c25b45/filterconfig_html.py