Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 34695:e178fcaa3933
python3: use our bytes-only version of cgi.escape everywhere
As suggested by Yuya in D965.
Differential Revision: https://phab.mercurial-scm.org/D1067
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 05 Oct 2017 14:16:20 -0400 |
parents | 0fa781320203 |
children | 4fdc4adbc838 |
comparison
equal
deleted
inserted
replaced
34694:2976cf87a60a | 34695:e178fcaa3933 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import cgi | |
11 import os | 10 import os |
12 import re | 11 import re |
13 import time | 12 import time |
14 | 13 |
15 from . import ( | 14 from . import ( |
17 hbisect, | 16 hbisect, |
18 node, | 17 node, |
19 pycompat, | 18 pycompat, |
20 registrar, | 19 registrar, |
21 templatekw, | 20 templatekw, |
21 url, | |
22 util, | 22 util, |
23 ) | 23 ) |
24 | 24 |
25 urlerr = util.urlerr | 25 urlerr = util.urlerr |
26 urlreq = util.urlreq | 26 urlreq = util.urlreq |
126 @templatefilter('escape') | 126 @templatefilter('escape') |
127 def escape(text): | 127 def escape(text): |
128 """Any text. Replaces the special XML/XHTML characters "&", "<" | 128 """Any text. Replaces the special XML/XHTML characters "&", "<" |
129 and ">" with XML entities, and filters out NUL characters. | 129 and ">" with XML entities, and filters out NUL characters. |
130 """ | 130 """ |
131 return cgi.escape(text.replace('\0', ''), True) | 131 return url.escape(text.replace('\0', ''), True) |
132 | 132 |
133 para_re = None | 133 para_re = None |
134 space_re = None | 134 space_re = None |
135 | 135 |
136 def fill(text, width, initindent='', hangindent=''): | 136 def fill(text, width, initindent='', hangindent=''): |