mirror of https://github.com/craigerl/aprsd.git
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!
This commit is contained in:
parent
873fc06608
commit
f400c6004e
|
@ -171,7 +171,10 @@ class Packet:
|
||||||
|
|
||||||
message = msg[:67]
|
message = msg[:67]
|
||||||
# We all miss George Carlin
|
# 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:
|
def __str__(self) -> str:
|
||||||
"""Show the raw version of the packet"""
|
"""Show the raw version of the packet"""
|
||||||
|
|
|
@ -272,8 +272,8 @@ class TestPacketBase(unittest.TestCase):
|
||||||
|
|
||||||
# test with bad words
|
# test with bad words
|
||||||
# Currently fails with mixed case
|
# Currently fails with mixed case
|
||||||
message = "My cunt piss fuck text"
|
message = "My cunt piss fuck shIt text"
|
||||||
exp_msg = "My **** **** **** text"
|
exp_msg = "My **** **** **** **** text"
|
||||||
msgno = "ABX"
|
msgno = "ABX"
|
||||||
packet = packets.MessagePacket(
|
packet = packets.MessagePacket(
|
||||||
from_call=fake.FAKE_FROM_CALLSIGN,
|
from_call=fake.FAKE_FROM_CALLSIGN,
|
||||||
|
|
Loading…
Reference in New Issue