Skip to content

Commit 2b32c29

Browse files
committed
fix arbitrary position in the sanitized URL
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 4cceb9b commit 2b32c29

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

workflow/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import logging
1111
import os
12+
from urllib.parse import urlparse
1213

1314
from django.conf import settings
1415
from django.contrib.contenttypes.fields import GenericForeignKey
@@ -589,7 +590,7 @@ def get_involved_users(self, exclude=None):
589590
return users
590591

591592
def serialize_hook(self, hook):
592-
if "hooks.slack.com" in hook.target_url:
593+
if urlparse(hook.target_url).hostname == "hooks.slack.com":
593594
return request_slack_payload(self, created="added" in hook.event)
594595

595596
from workflow.api import RequestSerializer
@@ -789,7 +790,7 @@ def as_html(self):
789790
return mark_safe(html)
790791

791792
def serialize_hook(self, hook):
792-
if "hooks.slack.com" in hook.target_url:
793+
if urlparse(hook.target_url).hostname == "hooks.slack.com":
793794
return request_comment_slack_payload(self)
794795

795796
from workflow.api import RequestCommentSerializer

0 commit comments

Comments
 (0)