Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
26419:93bfa9fc96e3 | 26502:4ca98a389152 |
---|---|
647 splitter = stringify(args[2][0](context, mapping, args[2][1])) | 647 splitter = stringify(args[2][0](context, mapping, args[2][1])) |
648 else: | 648 else: |
649 splitter = None | 649 splitter = None |
650 | 650 |
651 tokens = text.split(splitter) | 651 tokens = text.split(splitter) |
652 if num >= len(tokens): | 652 if num >= len(tokens) or num < -len(tokens): |
653 return '' | 653 return '' |
654 else: | 654 else: |
655 return tokens[num] | 655 return tokens[num] |
656 | 656 |
657 # methods to interpret function arguments or inner expressions (e.g. {_(x)}) | 657 # methods to interpret function arguments or inner expressions (e.g. {_(x)}) |