19
19
20
20
"""Simple WSGI application to check numbers."""
21
21
22
+ import html
22
23
import inspect
23
24
import json
24
25
import os
@@ -69,7 +70,7 @@ def info(module, number):
69
70
70
71
def format (data ):
71
72
"""Return an HTML snippet describing the number."""
72
- description = cgi .escape (data ['description' ]).replace ('\n \n ' , '<br/>\n ' )
73
+ description = html .escape (data ['description' ]).replace ('\n \n ' , '<br/>\n ' )
73
74
description = re .sub (
74
75
r'^[*] (.*)$' , r'<ul><li>\1</li></ul>' ,
75
76
description , flags = re .MULTILINE )
@@ -79,10 +80,10 @@ def format(data):
79
80
description , flags = re .IGNORECASE + re .UNICODE )
80
81
for name , conversion in data .get ('conversions' , {}).items ():
81
82
description += '\n <br/><b><i>%s</i></b>: %s' % (
82
- cgi .escape (name ), cgi .escape (conversion ))
83
+ html .escape (name ), html .escape (conversion ))
83
84
return '<li>%s: <b>%s</b><p>%s</p></li>' % (
84
- cgi .escape (data ['number' ]),
85
- cgi .escape (data ['name' ]),
85
+ html .escape (data ['number' ]),
86
+ html .escape (data ['name' ]),
86
87
description )
87
88
88
89
@@ -115,5 +116,5 @@ def application(environ, start_response):
115
116
('Content-Type' , 'text/html; charset=utf-8' ),
116
117
('Vary' , 'X-Requested-With' )])
117
118
return [(_template % dict (
118
- value = cgi .escape (number , True ),
119
+ value = html .escape (number , True ),
119
120
results = u'\n ' .join (format (data ) for data in results ))).encode ('utf-8' )]
0 commit comments