mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-01 13:17:59 +00:00
🔒️(ci) escape the downloaded gitmojis before the regex
The rule joins the list it fetches into an alternation, so any regex character in a gitmoji entry would change what the pattern matches. re.escape treats each one as a literal, which is what the match was always meant to do.
This commit is contained in:
@@ -30,7 +30,7 @@ class GitmojiTitle(LineRule):
|
||||
"""
|
||||
with urllib.request.urlopen(GITMOJIS_URL, timeout=10) as response:
|
||||
gitmojis = json.load(response)["gitmojis"]
|
||||
emojis = [item["emoji"] for item in gitmojis]
|
||||
emojis = [re.escape(item["emoji"]) for item in gitmojis]
|
||||
pattern = r"^({:s})\(.*\)\s[a-z].*$".format("|".join(emojis))
|
||||
if not re.search(pattern, title):
|
||||
violation_msg = 'Title does not match regex "<gitmoji>(<scope>) <subject>"'
|
||||
|
||||
Reference in New Issue
Block a user