Skip to content

Commit e4a8932

Browse files
author
Richard Jones
committed
fix cross-site-scripting bug
1 parent 385c92c commit e4a8932

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

roundup/cgi/client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.118 2003-06-09 23:17:23 richard Exp $
1+
# $Id: client.py,v 1.119 2003-06-10 22:55:30 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -68,6 +68,13 @@ def initialiseSecurity(security):
6868
description="User may manipulate user Roles through the web")
6969
security.addPermissionToRole('Admin', p)
7070

71+
def clean_message(match, ok={'a':1,'i':1,'b':1,'br':1}):
72+
''' Strip all non <a>,<i>,<b> and <br> tags from a string
73+
'''
74+
if ok.has_key(match.group(2)):
75+
return match.group(1)
76+
return '&lt;%s&gt;'%match.group(2)
77+
7178
class Client:
7279
''' Instantiate to handle one CGI request.
7380
@@ -341,7 +348,8 @@ def determine_user(self):
341348
# reopen the database as the correct user
342349
self.opendb(self.user)
343350

344-
def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
351+
def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)'),
352+
mc=re.compile(r'(</?(.*?)>)')):
345353
''' Determine the context of this page from the URL:
346354
347355
The URL path after the instance identifier is examined. The path
@@ -389,8 +397,10 @@ def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
389397
template_override = self.form[key].value
390398
elif self.FV_OK_MESSAGE.match(key):
391399
ok_message = self.form[key].value
400+
ok_message = mc.sub(clean_message, ok_message)
392401
elif self.FV_ERROR_MESSAGE.match(key):
393402
error_message = self.form[key].value
403+
error_message = mc.sub(clean_message, error_message)
394404

395405
# determine the classname and possibly nodeid
396406
path = self.path.split('/')

templates/classic/html/_generic.help.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
</tr>
5050
<tr>
5151
<th>&nbsp;<b>x</b></th>
52-
<th tal:repeat="prop props" tal:content="prop"></th>
52+
<th tal:repeat="prop props" tal:content="structure prop"></th>
5353
</tr>
5454
</table>
5555

5656
</form>
5757
</body>
58-
</html>
58+
</html>

0 commit comments

Comments
 (0)