##// END OF EJS Templates
templates: introduce revescape filter for escaping symbolic revisions...
av6 -
r25778:3a334127 default
parent child Browse files
Show More
@@ -6,10 +6,11 b''
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 import os, copy, urllib
9 import os, copy
10 from mercurial import match, patch, error, ui, util, pathutil, context
10 from mercurial import match, patch, error, ui, util, pathutil, context
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 from mercurial.node import hex, nullid, short
12 from mercurial.node import hex, nullid, short
13 from mercurial.templatefilters import revescape
13 from common import ErrorResponse, paritygen
14 from common import ErrorResponse, paritygen
14 from common import HTTP_NOT_FOUND
15 from common import HTTP_NOT_FOUND
15 import difflib
16 import difflib
@@ -281,7 +282,7 b' def changelistentry(web, ctx, tmpl):'
281
282
282 def symrevorshortnode(req, ctx):
283 def symrevorshortnode(req, ctx):
283 if 'node' in req.form:
284 if 'node' in req.form:
284 return urllib.quote(req.form['node'][0])
285 return revescape(req.form['node'][0])
285 else:
286 else:
286 return short(ctx.node())
287 return short(ctx.node())
287
288
@@ -283,6 +283,13 b' def person(author):'
283 f = author.find('@')
283 f = author.find('@')
284 return author[:f].replace('.', ' ')
284 return author[:f].replace('.', ' ')
285
285
286 def revescape(text):
287 """:revescape: Any text. Escapes all "special" characters, except @.
288 Forward slashes are escaped twice to prevent web servers from prematurely
289 unescaping them. For example, "@foo bar/baz" becomes "@foo%20bar%252Fbaz".
290 """
291 return urllib.quote(text, safe='/@').replace('/', '%252F')
292
286 def rfc3339date(text):
293 def rfc3339date(text):
287 """:rfc3339date: Date. Returns a date using the Internet date format
294 """:rfc3339date: Date. Returns a date using the Internet date format
288 specified in RFC 3339: "2009-08-18T13:00:13+02:00".
295 specified in RFC 3339: "2009-08-18T13:00:13+02:00".
@@ -402,6 +409,7 b' filters = {'
402 "obfuscate": obfuscate,
409 "obfuscate": obfuscate,
403 "permissions": permissions,
410 "permissions": permissions,
404 "person": person,
411 "person": person,
412 "revescape": revescape,
405 "rfc3339date": rfc3339date,
413 "rfc3339date": rfc3339date,
406 "rfc822date": rfc822date,
414 "rfc822date": rfc822date,
407 "short": short,
415 "short": short,
General Comments 0
You need to be logged in to leave comments. Login now