From 1a65d12b2ca681a76fa4976c98fa41afe19f21cc Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 3 Mar 2014 12:26:57 +0100 Subject: [PATCH] Fixed a bug in strip_ansi that caused issues all over. --- src/commands/default/admin.py | 2 +- src/utils/ansi.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/commands/default/admin.py b/src/commands/default/admin.py index e4f000e118..9c6ddb40f2 100644 --- a/src/commands/default/admin.py +++ b/src/commands/default/admin.py @@ -204,7 +204,7 @@ class CmdBan(MuxCommand): # save updated banlist banlist.append(bantup) ServerConfig.objects.conf('server_bans', banlist) - self.caller.msg("%s-Ban {w%s{x was added." % (typ, ban)) + self.caller.msg("%s-Ban {w%s{n was added." % (typ, ban)) class CmdUnban(MuxCommand): diff --git a/src/utils/ansi.py b/src/utils/ansi.py index cfd352b518..d9e62e2883 100644 --- a/src/utils/ansi.py +++ b/src/utils/ansi.py @@ -205,9 +205,9 @@ class ANSIParser(object): if strip_ansi: # remove all ansi codes (including those manually # inserted in string) - return self.strip_ansi(string) + return self.strip_ansi(parsed_string) - # cache and crop old cache + # cache and crop old cache _PARSE_CACHE[cachekey] = parsed_string if len(_PARSE_CACHE) > _PARSE_CACHE_SIZE: _PARSE_CACHE.popitem(last=False) @@ -682,6 +682,13 @@ class ANSIString(unicode): other assumed to be what isn't in the first. """ # These are all the indexes which hold code characters. + #matches = [(match.start(), match.end()) + # for match in self.parser.ansi_regex.finditer(self._raw_string)] + #code_indexes = [] + # # These are all the indexes which hold code characters. + #for start, end in matches: + # code_indexes.extend(range(start, end)) + code_indexes = [] for match in self.parser.ansi_regex.finditer(self._raw_string): code_indexes.extend(range(match.start(), match.end()))