From 8e0e42a540d74c1f04d5497278099bce049a261d Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 5 Feb 2013 06:06:36 +0100 Subject: ext.widestring: Fix corner case (bug #32687) https://savannah.nongnu.org/bugs/index.php?32687 --- ranger/ext/widestring.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ranger/ext/widestring.py b/ranger/ext/widestring.py index 44972c9c..fbd84b0d 100644 --- a/ranger/ext/widestring.py +++ b/ranger/ext/widestring.py @@ -88,6 +88,8 @@ class WideString(object): """ >>> WideString("asdf")[1:3] + >>> WideString("asdf")[1:-100] + >>> WideString("モヒカン")[2:4] >>> WideString("モヒカン")[2:5] @@ -107,6 +109,10 @@ class WideString(object): """ if z is None or z > len(self.chars): z = len(self.chars) + if z < 0: + z = len(self.chars) + z + if z < 0: + return WideString("") if a is None or a < 0: a = 0 if z < len(self.chars) and self.chars[z] == '': -- cgit 1.4.1-2-gfad0