Skip to content

Commit 029150e

Browse files
committed
plugins/correction: Disable regex-replacements for now since they can be dangerous, now literal replacements are done.
1 parent 2ac27c6 commit 029150e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

plugins/correction.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@ def correction(match, conn, chan, message):
1818
find = groups[0]
1919
replacement = groups[1]
2020
flags = groups[2] if len(groups) == 3 else ""
21-
find_re = re.compile("{}{}".format("(?{})".format(flags.replace("g", ""))
22-
if flags.replace("g", "") != "" else "", find))
21+
find_re = find
22+
#find_re = re.compile("{}{}".format("(?{})".format(flags.replace("g", ""))
23+
# if flags.replace("g", "") != "" else "", find))
2324

2425
for item in conn.history[chan].__reversed__():
2526
nick, timestamp, msg = item
2627
if correction_re.match(msg):
2728
# don't correct corrections, it gets really confusing
2829
continue
29-
if find_re.search(msg):
30+
#if find_re.search(msg):
31+
if find_re in msg:
3032
is_action = False
3133
if "\x01ACTION" in msg:
3234
is_action = True
3335
msg = msg.replace("\x01ACTION", "").replace("\x01", "")
34-
mod_msg = find_re.sub("\x02" + replacement + "\x02", msg, count=int("g" not in flags))
36+
#mod_msg = find_re.sub("\x02" + replacement + "\x02", msg, count=int("g" not in flags))
37+
mod_msg = msg.replace(find_re, "\x02" + replacement + "\x02")
3538
message("Correction, {}".format(("<{}> " if not is_action else "* {}").format(nick) + mod_msg))
3639
# append to end of history file
37-
msg = find_re.sub(replacement, msg, count=int("g" not in flags))
40+
#msg = find_re.sub(replacement, msg, count=int("g" not in flags))
41+
msg = msg.replace(find_re, replacement)
3842
conn.history[chan].append((nick, timestamp, msg))
3943
return
4044
else:

0 commit comments

Comments
 (0)