##// END OF EJS Templates
templater: do not process \-escapes at parsestring() (issue4290)...
Yuya Nishihara -
r24948:db7463aa stable
parent child Browse files
Show More
@@ -618,14 +618,13 b' def _flatten(thing):'
618 618 yield j
619 619
620 620 def parsestring(s, quoted=True):
621 '''parse a string using simple c-like syntax.
622 string must be in quotes if quoted is True.'''
621 '''unwrap quotes if quoted is True'''
623 622 if quoted:
624 623 if len(s) < 2 or s[0] != s[-1]:
625 624 raise SyntaxError(_('unmatched quotes'))
626 return s[1:-1].decode('string_escape')
625 return s[1:-1]
627 626
628 return s.decode('string_escape')
627 return s
629 628
630 629 class engine(object):
631 630 '''template expansion engine.
@@ -2250,6 +2250,29 b' Test string escaping:'
2250 2250 <>\n<]>
2251 2251 <>\n<
2252 2252
2253 $ hg log -R latesttag -r 0 \
2254 > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2255 >
2256 <>\n<[>
2257 <>\n<]>
2258 <>\n<
2259
2260 $ hg log -R latesttag -r 0 -T esc \
2261 > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2262 >
2263 <>\n<[>
2264 <>\n<]>
2265 <>\n<
2266
2267 $ cat <<'EOF' > esctmpl
2268 > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
2269 > EOF
2270 $ hg log -R latesttag -r 0 --style ./esctmpl
2271 >
2272 <>\n<[>
2273 <>\n<]>
2274 <>\n<
2275
2253 2276 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
2254 2277
2255 2278 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
General Comments 0
You need to be logged in to leave comments. Login now