|
1 | | -# $Id: client.py,v 1.65.2.6 2003-03-19 02:50:12 richard Exp $ |
| 1 | +<<<<<<< client.py |
| 2 | +# $Id: client.py,v 1.65.2.7 2003-06-10 22:59:22 richard Exp $ |
| 3 | +======= |
| 4 | +# $Id: client.py,v 1.65.2.7 2003-06-10 22:59:22 richard Exp $ |
| 5 | +>>>>>>> 1.119 |
2 | 6 |
|
3 | 7 | __doc__ = """ |
4 | 8 | WWW request handler (also used in the stand-alone server). |
@@ -47,6 +51,13 @@ def initialiseSecurity(security): |
47 | 51 | description="User may manipulate user Roles through the web") |
48 | 52 | security.addPermissionToRole('Admin', p) |
49 | 53 |
|
| 54 | +def clean_message(match, ok={'a':1,'i':1,'b':1,'br':1}): |
| 55 | + ''' Strip all non <a>,<i>,<b> and <br> tags from a string |
| 56 | + ''' |
| 57 | + if ok.has_key(match.group(2)): |
| 58 | + return match.group(1) |
| 59 | + return '<%s>'%match.group(2) |
| 60 | + |
50 | 61 | class Client: |
51 | 62 | ''' Instantiate to handle one CGI request. |
52 | 63 |
|
@@ -249,7 +260,8 @@ def determine_user(self): |
249 | 260 | # reopen the database as the correct user |
250 | 261 | self.opendb(self.user) |
251 | 262 |
|
252 | | - def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')): |
| 263 | + def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)'), |
| 264 | + mc=re.compile(r'(</?(.*?)>)')): |
253 | 265 | ''' Determine the context of this page from the URL: |
254 | 266 |
|
255 | 267 | The URL path after the instance identifier is examined. The path |
@@ -331,9 +343,11 @@ def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')): |
331 | 343 |
|
332 | 344 | # see if we were passed in a message |
333 | 345 | if self.form.has_key(':ok_message'): |
334 | | - self.ok_message.append(self.form[':ok_message'].value) |
| 346 | + msg = mc.sub(clean_message, self.form[':ok_message'].value) |
| 347 | + self.ok_message.append(msg) |
335 | 348 | if self.form.has_key(':error_message'): |
336 | | - self.error_message.append(self.form[':error_message'].value) |
| 349 | + msg = mc.sub(clean_message, self.form[':error_message'].value) |
| 350 | + self.error_message.append(msg) |
337 | 351 |
|
338 | 352 | def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')): |
339 | 353 | ''' Serve the file from the content property of the designated item. |
|
0 commit comments