-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxss-filter.py
More file actions
45 lines (37 loc) · 1.09 KB
/
xss-filter.py
File metadata and controls
45 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import sys
import web, pxfilter
urls = (
'.*', 'router'
)
class su:
def other(self):
raise web.seeother('main')
class router(su):
def __init__(self):
self.tplData = {}
self.globalsTplFuncs = {}
web.header("X-XSS-Protection", "0")
def GET(self):
self.assign("html", "")
return self.display("xsshtml")
def POST(self):
html = web.input(xsscode = "").xsscode
parser = pxfilter.XssHtml()
parser.feed(html)
parser.close()
html = parser.getHtml()
self.assign("html", html)
return self.display("xsshtml")
def assign(self,key,value = ''):
if type(key) == dict:
self.tplData = dict(self.tplData, **key)
else:
self.tplData[key] = value
def display(self, tplName):
self.tplData['render'] = web.template.render('html', globals = self.globalsTplFuncs)
return getattr(self.tplData['render'], tplName)(self.tplData)
if __name__ == '__main__':
app = web.application(urls, globals())
web.config.debug = True
app.run()