diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -7,7 +7,6 @@ from __future__ import absolute_import -import cgi import copy import mimetypes import os @@ -38,6 +37,7 @@ smartset, templatefilters, templater, + url, util, ) @@ -1250,9 +1250,9 @@ node = str(ctx) age = encodestr(templatefilters.age(ctx.date())) desc = templatefilters.firstline(encodestr(ctx.description())) - desc = cgi.escape(templatefilters.nonempty(desc)) - user = cgi.escape(templatefilters.person(encodestr(ctx.user()))) - branch = cgi.escape(encodestr(ctx.branch())) + desc = url.escape(templatefilters.nonempty(desc)) + user = url.escape(templatefilters.person(encodestr(ctx.user()))) + branch = url.escape(encodestr(ctx.branch())) try: branchnode = web.repo.branchtip(branch) except error.RepoLookupError: @@ -1261,8 +1261,8 @@ if usetuples: data.append((node, vtx, edges, desc, user, age, branch, - [cgi.escape(encodestr(x)) for x in ctx.tags()], - [cgi.escape(encodestr(x)) + [url.escape(encodestr(x)) for x in ctx.tags()], + [url.escape(encodestr(x)) for x in ctx.bookmarks()])) else: edgedata = [{'col': edge[0], 'nextcol': edge[1], diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -20,13 +20,13 @@ from __future__ import absolute_import -import cgi import re from .i18n import _ from . import ( encoding, pycompat, + url, util, ) @@ -552,7 +552,7 @@ listnest = [] def escape(s): - return cgi.escape(s, True) + return url.escape(s, True) def openlist(start, level): if not listnest or listnest[-1][0] != start: diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -7,7 +7,6 @@ from __future__ import absolute_import -import cgi import os import re import time @@ -19,6 +18,7 @@ pycompat, registrar, templatekw, + url, util, ) @@ -128,7 +128,7 @@ """Any text. Replaces the special XML/XHTML characters "&", "<" and ">" with XML entities, and filters out NUL characters. """ - return cgi.escape(text.replace('\0', ''), True) + return url.escape(text.replace('\0', ''), True) para_re = None space_re = None