From f400c6004e74b71a482429fc56d7595796fb5748 Mon Sep 17 00:00:00 2001 From: Hemna Date: Sat, 23 Mar 2024 18:02:01 -0400 Subject: [PATCH] Fix for filtering curse words This patch adds a fix for filtering out curse words. This adds a flag to the regex to ignore case! --- aprsd/packets/core.py | 5 ++++- tests/test_packets.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/aprsd/packets/core.py b/aprsd/packets/core.py index 861cabf..812f6b8 100644 --- a/aprsd/packets/core.py +++ b/aprsd/packets/core.py @@ -171,7 +171,10 @@ class Packet: message = msg[:67] # We all miss George Carlin - return re.sub("fuck|shit|cunt|piss|cock|bitch", "****", message) + return re.sub( + "fuck|shit|cunt|piss|cock|bitch", "****", + message, flags=re.IGNORECASE, + ) def __str__(self) -> str: """Show the raw version of the packet""" diff --git a/tests/test_packets.py b/tests/test_packets.py index a9774e0..9fe7990 100644 --- a/tests/test_packets.py +++ b/tests/test_packets.py @@ -272,8 +272,8 @@ class TestPacketBase(unittest.TestCase): # test with bad words # Currently fails with mixed case - message = "My cunt piss fuck text" - exp_msg = "My **** **** **** text" + message = "My cunt piss fuck shIt text" + exp_msg = "My **** **** **** **** text" msgno = "ABX" packet = packets.MessagePacket( from_call=fake.FAKE_FROM_CALLSIGN,