Code

fix cross-site-scripting bug
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 10 Jun 2003 22:55:30 +0000 (22:55 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 10 Jun 2003 22:55:30 +0000 (22:55 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1725 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/client.py
templates/classic/html/_generic.help.html

index c08ec82994ddc1e94deffa60802ce4da9f0897cf..03aa4ab44875d8ee0b671dc9c9407c78adcccdb9 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.118 2003-06-09 23:17:23 richard Exp $
+# $Id: client.py,v 1.119 2003-06-10 22:55:30 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -68,6 +68,13 @@ def initialiseSecurity(security):
         description="User may manipulate user Roles through the web")
     security.addPermissionToRole('Admin', p)
 
+def clean_message(match, ok={'a':1,'i':1,'b':1,'br':1}):
+    ''' Strip all non <a>,<i>,<b> and <br> tags from a string
+    '''
+    if ok.has_key(match.group(2)):
+        return match.group(1)
+    return '&lt;%s&gt;'%match.group(2)
+
 class Client:
     ''' Instantiate to handle one CGI request.
 
@@ -341,7 +348,8 @@ class Client:
         # reopen the database as the correct user
         self.opendb(self.user)
 
-    def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
+    def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)'),
+            mc=re.compile(r'(</?(.*?)>)')):
         ''' Determine the context of this page from the URL:
 
             The URL path after the instance identifier is examined. The path
@@ -389,8 +397,10 @@ class Client:
                 template_override = self.form[key].value
             elif self.FV_OK_MESSAGE.match(key):
                 ok_message = self.form[key].value
+                ok_message = mc.sub(clean_message, ok_message)
             elif self.FV_ERROR_MESSAGE.match(key):
                 error_message = self.form[key].value
+                error_message = mc.sub(clean_message, error_message)
 
         # determine the classname and possibly nodeid
         path = self.path.split('/')
index 803c171c7845e5a5a4ef3c270198362f8d3cb11e..433df78c53d5016ebf1626a846d46ed9e13eeab2 100644 (file)
        </tr>
        <tr>
            <th>&nbsp;<b>x</b></th>
-           <th tal:repeat="prop props" tal:content="prop"></th>
+           <th tal:repeat="prop props" tal:content="structure prop"></th>
        </tr>
      </table>
 
  </form>
  </body>
-</html>
\ No newline at end of file
+</html>