Mercurial > p > roundup > code
comparison roundup/cgi/exceptions.py @ 5800:1a835db41674
Call cgi.escape only on python 2. Replace with html.escapeif it can be
found.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 11 Jun 2019 21:29:24 -0400 |
| parents | 07abc8d36940 |
| children | 883c9e90b403 |
comparison
equal
deleted
inserted
replaced
| 5799:7ba0ee980fc7 | 5800:1a835db41674 |
|---|---|
| 2 """ | 2 """ |
| 3 | 3 |
| 4 __docformat__ = 'restructuredtext' | 4 __docformat__ = 'restructuredtext' |
| 5 | 5 |
| 6 from roundup.exceptions import LoginError, Unauthorised | 6 from roundup.exceptions import LoginError, Unauthorised |
| 7 import cgi | 7 |
| 8 try: | |
| 9 from html import escape as html_escape # python 3 | |
| 10 except ImportError: | |
| 11 from cgi import escape as html_escape # python 2 fallback | |
| 8 | 12 |
| 9 class HTTPException(BaseException): | 13 class HTTPException(BaseException): |
| 10 pass | 14 pass |
| 11 | 15 |
| 12 class Redirect(HTTPException): | 16 class Redirect(HTTPException): |
| 60 <link rel="stylesheet" type="text/css" href="@@file/style.css"> | 64 <link rel="stylesheet" type="text/css" href="@@file/style.css"> |
| 61 </head> | 65 </head> |
| 62 <body class="body" marginwidth="0" marginheight="0"> | 66 <body class="body" marginwidth="0" marginheight="0"> |
| 63 <p class="error-message">%s</p> | 67 <p class="error-message">%s</p> |
| 64 </body></html> | 68 </body></html> |
| 65 """%cgi.escape(self.args[0]) | 69 """%html_escape(self.args[0]) |
| 66 | 70 |
| 67 # vim: set filetype=python sts=4 sw=4 et si : | 71 # vim: set filetype=python sts=4 sw=4 et si : |
