diff mercurial/templater.py @ 26502:4ca98a389152 stable

templater: protect word() from crashing on out of range negative value The function isn't documented to work with negative values at all, but it does, which can be useful. However, the range check didn't account for this.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 05 Oct 2015 12:37:26 -0400
parents e71e5629e006
children 875e5d89dc86 d3712209921d
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Oct 01 12:07:20 2015 -0500
+++ b/mercurial/templater.py	Mon Oct 05 12:37:26 2015 -0400
@@ -649,7 +649,7 @@
         splitter = None
 
     tokens = text.split(splitter)
-    if num >= len(tokens):
+    if num >= len(tokens) or num < -len(tokens):
         return ''
     else:
         return tokens[num]