Skip to content

Commit ce4198c

Browse files
committed
squashme
1 parent d3b0cf4 commit ce4198c

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

sopel/builtins/safety.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,10 @@ def url_handler(bot: SopelWrapper, trigger: Trigger) -> None:
263263
safe_url,
264264
)
265265
bot.say(
266-
"{} {} of {} engine{} flagged a link {} posted as malicious".format(
266+
"{} {} of {} engines flagged a link {} posted as malicious".format(
267267
bold(color("WARNING:", colors.RED)),
268268
positives,
269269
total,
270-
"" if total == 1 else "s",
271270
bold(trigger.nick),
272271
)
273272
)

test/builtins/test_builtins_safety.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,20 @@
88

99
URL_TESTS = (
1010
# Valid URLs
11-
("http://example.com", "hxxp://example[.]com"),
12-
("http://1.2.3.4/", "hxxp://1[.]2[.]3[.]4/"),
13-
("http://[fd00:1234::4321]/", "hxxp://[fd00[:]1234[:][:]4321]/"),
14-
("ftp://1.2.3.4/", "fxp://1[.]2[.]3[.]4/"),
11+
("http://example.com", ("hxxp://example[.]com")),
12+
("http://1.2.3.4/mgr.cgi", ("hxxp://1[.]2[.]3[.]4/mgr.cgi")),
13+
("http://[fd00:1234::4321]/", ("hxxp://[fd00[:]1234[:][:]4321]/")),
14+
("ftp://1.2.3.4/", ("fxp://1[.]2[.]3[.]4/")),
1515
# Invalid, but parsed anyway
16-
("http://<Target-IP>/", "hxxp://<Target-IP>/"),
17-
("http://1.2.3.4.5/", "hxxp://1[.]2[.]3[.]4[.]5/"),
18-
("http://555.555.555.555/", "hxxp://555[.]555[.]555[.]555/"),
19-
# Fallback path
20-
("http://[fd00:::]/", "http[:]//[fd00[:][:][:]]/"),
16+
("http://<placeholder>/", ("hxxp://<placeholder>/")),
17+
("http://1.2.3.4.5/", ("hxxp://1[.]2[.]3[.]4[.]5/")),
18+
("http://555.555.555.555/", ("hxxp://555[.]555[.]555[.]555/")),
19+
# urllib.urlparse() works in python <=3.10 but fails in 3.11
20+
("http://[fd00:::]/", ("hxxp://[fd00[:][:][:]]/", "http[:]//[fd00[:][:][:]]/")),
21+
("http://[placeholder]/", ("hxxp://[placeholder]/", "http[:]//[placeholder]/")),
2122
)
2223

2324

24-
@pytest.mark.parametrize("original, safed", URL_TESTS)
25-
def test_safeify_url(original, safed):
26-
assert safeify_url(original) == safed
27-
28-
29-
def test_safeify_maybe_parsefail():
30-
# Parse succeeds in python <=3.10 but fails in 3.11
31-
original = "http://[Target-IP]/account_mgr.cgi"
32-
parseok = "hxxp://[Target-IP]/account_mgr.cgi"
33-
parsefail = "http[:]//[Target-IP]/account_mgr[.]cgi"
34-
35-
assert safeify_url(original) in (parseok, parsefail)
25+
@pytest.mark.parametrize("original, safed_options", URL_TESTS)
26+
def test_safeify_url(original, safed_options):
27+
assert safeify_url(original) in safed_options

0 commit comments

Comments
 (0)