From f86a488231dc9a629d44a9f6aa6bfc9aa0eb57b4 Mon Sep 17 00:00:00 2001 From: Squire Date: Fri, 17 Jun 2011 11:05:31 -0700 Subject: CHOP-662 - initial fix to problems with regex characters in Group names causing the LLDirIterator to crash the viewer when opening chat logs --- indra/llvfs/lldiriterator.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/llvfs/lldiriterator.cpp') diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp index 041436ed92..3b132862ad 100644 --- a/indra/llvfs/lldiriterator.cpp +++ b/indra/llvfs/lldiriterator.cpp @@ -121,6 +121,14 @@ bool LLDirIterator::Impl::next(std::string &fname) return found; } +/* +converts the incoming glob into a regex. This involves +converting incoming glob expressions to regex equivilents and +at the same time, escaping any regex meaningful characters which +do not have glob meaning, i.e. + .()+|^$ +in the input +*/ std::string glob_to_regex(const std::string& glob) { std::string regex; @@ -135,9 +143,6 @@ std::string glob_to_regex(const std::string& glob) switch (c) { - case '.': - regex+="\\."; - break; case '*': if (glob.begin() == i) { @@ -170,7 +175,15 @@ std::string glob_to_regex(const std::string& glob) case '!': regex+= square_brace_open ? '^' : c; break; - default: + case '.': // This collection have different regex meaning + case '^': // And so need escaping + case '(': + case ')': + case '+': + case '|': + case '$': + regex+='\\'; + default: regex+=c; break; } -- cgit v1.2.3 From 14105610c7fb295a16b3b2a88014004c62ffa265 Mon Sep 17 00:00:00 2001 From: Squire Date: Tue, 21 Jun 2011 20:46:32 -0700 Subject: CHOP-662 cleanup in response to code review. --- indra/llvfs/lldiriterator.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llvfs/lldiriterator.cpp') diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp index 3b132862ad..25550321f0 100644 --- a/indra/llvfs/lldiriterator.cpp +++ b/indra/llvfs/lldiriterator.cpp @@ -121,13 +121,13 @@ bool LLDirIterator::Impl::next(std::string &fname) return found; } -/* -converts the incoming glob into a regex. This involves +/** +Converts the incoming glob into a regex. This involves converting incoming glob expressions to regex equivilents and at the same time, escaping any regex meaningful characters which do not have glob meaning, i.e. .()+|^$ -in the input +in the input. */ std::string glob_to_regex(const std::string& glob) { @@ -176,15 +176,15 @@ std::string glob_to_regex(const std::string& glob) regex+= square_brace_open ? '^' : c; break; case '.': // This collection have different regex meaning - case '^': // And so need escaping + case '^': // and so need escaping. case '(': case ')': case '+': case '|': case '$': - regex+='\\'; - default: - regex+=c; + regex += '\\'; + default: + regex += c; break; } -- cgit v1.2.3