🔒️(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:
davd-gzl
2026-08-25 18:57:09 +00:00
committed by aleb_the_flash
parent fbeb035f50
commit 02a355136f
+1 -1
View File
@@ -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>"'