Skip to content

Commit

Permalink
Make blacklisted URL comparison case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
impredicative committed Aug 21, 2020
1 parent 97a5804 commit 0351f84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ It is recommended that the alerts channel be registered and monitored.
* **`blacklist/title`**: This is a list of strings. If a title is one of these strings, it is not posted.
The comparison is case insensitive.
* **`blacklist/url`**: This is a list of strings. If a URL is one of these strings, its title is not posted.
The comparison is case sensitive.
The comparison is case insensitive.
* **`ignores`**: This is a list of nicks to ignore.
* **`mode`**: This can for example be `+igR` for [Freenode](https://freenode.net/kb/answer/usermodes).
Setting it is recommended.
Expand Down
1 change: 1 addition & 0 deletions ircurltitlebot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def load_config() -> None:
blacklists["title"] = set(blacklists.get("title", set()))
blacklists["title"] = {entry.casefold() for entry in blacklists["title"]}
blacklists["url"] = set(blacklists.get("url", set()))
blacklists["url"] = {entry.casefold() for entry in blacklists["url"]}

config.INSTANCE = instance_config

Expand Down
2 changes: 1 addition & 1 deletion ircurltitlebot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _handle_privmsg(irc: miniirc.IRC, hostmask: Tuple[str, str, str], args: List
urls = [url[0] for url in itertools.groupby(urls)] # Guarantees consecutive uniqueness. https://git.io/fjeWl
# urls = [url for url in urls if not re.fullmatch(r'[^@]+@[^@]+\.[^@]+', url)] # Skips emails. https://git.io/fjeW3
urls = [url for url in urls if urlparse(url).scheme not in ("file", "git")] # Alt: scheme in ('http', 'https', '')
urls = [url for url in urls if url not in config.INSTANCE["blacklist"]["url"]]
urls = [url for url in urls if url.casefold() not in config.INSTANCE["blacklist"]["url"]]
if urls:
urls_str = ", ".join(urls)
log.debug("Incoming message from %s in %s has %s URLs to process: %s", user, channel, len(urls), urls_str)
Expand Down

0 comments on commit 0351f84

Please sign in to comment.