diff --git a/imap_filter/imap_filter.py b/imap_filter/imap_filter.py index 22349ff..aced2bc 100644 --- a/imap_filter/imap_filter.py +++ b/imap_filter/imap_filter.py @@ -211,16 +211,21 @@ class ImapFilter: ) search = f"^.* # imap_filter: rule name 'imap_filter_INBOX_{mfilter['name']}'$" replacement = f'if {condition} {{ fileinto "{mfilter['destination']}"; stop;}} # imap_filter: rule name \'imap_filter_INBOX_{mfilter['name']}\'' + self._log.debug( + "New filter script '%s'", + replacement + ) match = re.search(search, content, re.MULTILINE) if match: self._log.debug( "Line '%s' found in current file", search ) - new_content = re.sub(search, replacement, content) + # new_content = re.sub(search, replacement, content) + new_content = content.replace(search, replacement) if content != new_content: self._log.debug( - "It's different, so replacing it with '%s'", + "Line it's different, so replacing it with '%s'", replacement ) content = f"{new_content}\n"