Mercurial > p > roundup > code
comparison roundup/cgi/wsgi_handler.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 | 5579fa034f9e |
| children | e7b30ab60941 |
comparison
equal
deleted
inserted
replaced
| 5799:7ba0ee980fc7 | 5800:1a835db41674 |
|---|---|
| 5 # | 5 # |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import cgi | 8 import cgi |
| 9 import weakref | 9 import weakref |
| 10 | |
| 11 try: | |
| 12 from html import escape as html_escape # python 3 | |
| 13 except ImportError: | |
| 14 from cgi import escape as html_escape # python 2 fallback | |
| 10 | 15 |
| 11 import roundup.instance | 16 import roundup.instance |
| 12 from roundup.cgi import TranslationService | 17 from roundup.cgi import TranslationService |
| 13 from roundup.anypy import http_ | 18 from roundup.anypy import http_ |
| 14 from roundup.anypy.strings import s2b, bs2b | 19 from roundup.anypy.strings import s2b, bs2b |
| 67 request.translator) | 72 request.translator) |
| 68 try: | 73 try: |
| 69 client.main() | 74 client.main() |
| 70 except roundup.cgi.client.NotFound: | 75 except roundup.cgi.client.NotFound: |
| 71 request.start_response([('Content-Type', 'text/html')], 404) | 76 request.start_response([('Content-Type', 'text/html')], 404) |
| 72 request.wfile.write(s2b('Not found: %s'%cgi.escape(client.path))) | 77 request.wfile.write(s2b('Not found: %s'%html_escape(client.path))) |
| 73 | 78 |
| 74 # all body data has been written using wfile | 79 # all body data has been written using wfile |
| 75 return [] | 80 return [] |
| 76 | 81 |
| 77 def start_response(self, headers, response_code): | 82 def start_response(self, headers, response_code): |
