From a6fc9c40f7581a9c6b3a70fcf20d559cb6664e9a Mon Sep 17 00:00:00 2001 From: "jasonlei@umich.edu" Date: Fri, 10 Apr 2026 16:40:48 -0400 Subject: [PATCH 1/2] apply_corrections.py 1.4: fixing bug #359 using regex module --- python/apply_corrections.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/apply_corrections.py b/python/apply_corrections.py index 078fc1bb..5aea8e5d 100644 --- a/python/apply_corrections.py +++ b/python/apply_corrections.py @@ -57,7 +57,9 @@ # enough correction string. # History: -# +# 2026-04-10, Jason Lei : +# version 1.4: using regex module instead of re to prevent CPU hang in +# get_corrected_messages # 2018-06-21, Chris Johnson : # version 1.3: support python3 # 2014-05-10, Sébastien Helleu @@ -98,7 +100,7 @@ SCRIPT_NAME = 'apply_corrections' SCRIPT_AUTHOR = 'Chris Johnson ' -SCRIPT_VERSION = '1.3' +SCRIPT_VERSION = '1.4' SCRIPT_LICENSE = 'GPL3' SCRIPT_DESC = "When a correction (ex: s/typo/replacement) is sent, print the "\ "user's previous message(s) with the corrected text instead." @@ -115,6 +117,7 @@ try: import re import time + import regex from operator import itemgetter from collections import defaultdict except ImportError as message: @@ -163,7 +166,7 @@ def get_corrected_messages(nick, log, correction): original = message.get('message', '') if original: try: - match = re.match(re.compile('.*{}.*'.format(pattern)), original) + match = regex.search(pattern, original) except: match = original.find(pattern) != -1 finally: From 3b2f6f9c4c745cdd07c14719623d51ae0254fd9d Mon Sep 17 00:00:00 2001 From: "jasonlei@umich.edu" Date: Fri, 10 Apr 2026 19:17:35 -0400 Subject: [PATCH 2/2] apply_corrections.py 1.4: fixing bug #359 using regex module --- python/apply_corrections.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/apply_corrections.py b/python/apply_corrections.py index 5aea8e5d..10443714 100644 --- a/python/apply_corrections.py +++ b/python/apply_corrections.py @@ -2,6 +2,9 @@ # # Copyright (C) 2012 Chris Johnson # +# SPDX-FileCopyrightText: 2012 Chris Johnson +# SPDX-License-Identifier: GPL-3.0-or-later +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -111,7 +114,7 @@ import weechat except ImportError: print('This script must be run under WeeChat.') - print('Get WeeChat now at: http://www.weechat.org/') + print('Get WeeChat now at: https://weechat.org/') import_ok = False try: @@ -261,7 +264,7 @@ def handle_message_cb(data, buffer, date, tags, disp, hl, nick, message): # incoming messages. # # Nick regex nicked from colorize_nicks available here: - # http://www.weechat.org/scripts/source/stable/colorize_nicks.py.html/ + # https://weechat.org/scripts/source/colorize_nicks.py.html/ valid_nick = r'([@~&!%+])?([-a-zA-Z0-9\[\]\\`_^\{|\}]+)' valid_correction = r's/[^/]*/[^/]*' correction_message_pattern = re.compile(