From: Lertsenem Date: Wed, 12 Oct 2016 21:54:04 +0000 (+0200) Subject: Correction on comment-detection regexp X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6bb36e28788f8763ccad6ef4f1afa2122e526569;p=rainbowstream.git Correction on comment-detection regexp During the config parse, comments are removed using a complex regexp, matching (among other things) '//'. A problem arises when your configuration contains a link of some sort (such as 'http://' ...). The regexp then consider the '//' and what follows as a comment (and your configuration is consequently considered corrupt). Escapinf the '/' works for a time, but it fails as soon as you use the 'config' command at runtime, because the configuration is then rewritten. Therefore I changed the regexp used to match comments. It's a fairly complex regexp though, and I'm not 100% positive my change is perfect. Fell free to review it. --- diff --git a/rainbowstream/colorset/config b/rainbowstream/colorset/config index 6bfd43e..54b76ff 100644 --- a/rainbowstream/colorset/config +++ b/rainbowstream/colorset/config @@ -24,7 +24,7 @@ // 'conversation': max tweet in a thread "CONVERSATION_MAX" : 30, // 'quote' format - "QUOTE_FORMAT" : "#comment https:\/\/twitter.com\/#owner\/status\/#tid", + "QUOTE_FORMAT" : "#comment https://twitter.com/#owner/status/#tid", // 'thread' meta format "THREAD_META_LEFT" : "(#id) #clock", "THREAD_META_RIGHT" : "#clock (#id)", diff --git a/rainbowstream/config.py b/rainbowstream/config.py index 1573cce..5f5b81b 100644 --- a/rainbowstream/config.py +++ b/rainbowstream/config.py @@ -6,7 +6,7 @@ from collections import OrderedDict # Regular expression for comments in config file comment_re = re.compile( - '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?', + '(^)[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?', re.DOTALL | re.MULTILINE )