##// END OF EJS Templates
url: add cgi.escape equivalent for bytestrings...
Augie Fackler -
r34695:2976cf87 default
parent child Browse files
Show More
@@ -30,6 +30,21 b' stringio = util.stringio'
30 urlerr = util.urlerr
30 urlerr = util.urlerr
31 urlreq = util.urlreq
31 urlreq = util.urlreq
32
32
33 def escape(s, quote=None):
34 '''Replace special characters "&", "<" and ">" to HTML-safe sequences.
35 If the optional flag quote is true, the quotation mark character (")
36 is also translated.
37
38 This is the same as cgi.escape in Python, but always operates on
39 bytes, whereas cgi.escape in Python 3 only works on unicodes.
40 '''
41 s = s.replace(b"&", b"&amp;")
42 s = s.replace(b"<", b"&lt;")
43 s = s.replace(b">", b"&gt;")
44 if quote:
45 s = s.replace(b'"', b"&quot;")
46 return s
47
33 class passwordmgr(object):
48 class passwordmgr(object):
34 def __init__(self, ui, passwddb):
49 def __init__(self, ui, passwddb):
35 self.ui = ui
50 self.ui = ui
General Comments 0
You need to be logged in to leave comments. Login now