diff hgext/color.py @ 20661:7e627fe63e5e stable

templater: avoid recursive evaluation of string literals completely Changeset 3d8bfe2ecf6d (released with 2.8.1) fixed "recursively evaluate string literals as templates" problem (issue4103) by introducing "_evalifliteral()". But some parts in template expressions below are still processed by the combination of "compiletemplate()" and "runtemplate()", and may cause same problem unexpectedly. - 'init' and 'hang' of 'fill(text, width, init, hang)' - 'expr' of 'sub(pat, repl, expr)' - 'label' of 'label(label, expr)' This patch processes them by "_evalifliteral()" instead of the combination of "compiletemplate()" and "runtemplate()" to avoid recursive evaluation of string literals completely.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 10 Mar 2014 01:01:42 +0900
parents 3d8bfe2ecf6d
children 0084fcd5d7e2
line wrap: on
line diff
--- a/hgext/color.py	Mon Mar 03 15:50:45 2014 +0900
+++ b/hgext/color.py	Mon Mar 10 01:01:42 2014 +0900
@@ -393,9 +393,7 @@
     if isinstance(repo, str):
         return thing
 
-    label = templater.stringify(args[0][0](context, mapping, args[0][1]))
-    label = templater.runtemplate(context, mapping,
-                                  templater.compiletemplate(label, context))
+    label = templater._evalifliteral(args[0], context, mapping)
 
     thing = templater.stringify(thing)
     label = templater.stringify(label)