Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lms/djangoapps/discussion/rest_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ def filter_spam_urls_from_html(html_string):
escaped = domain.replace(".", r"\.")
domain_pattern = rf"(\w+\.)*{escaped}(?:/\S*)*"
patterns.append(re.compile(rf"(https?://)?{domain_pattern}", re.IGNORECASE))
spaced_parts = list(domain)
spaced_pattern = "".join(
rf"{re.escape(char)}(?:\s| |\u00A0)*" if char != "." else r"\.(?:\s| |\u00A0)*"
for char in spaced_parts
)
spaced_pattern += r"(?:\/(?:\s| |\u00A0|\w)*)*"
patterns.append(re.compile(spaced_pattern, re.IGNORECASE))

for a_tag in soup.find_all("a", href=True):
href = a_tag.get('href')
Expand Down
4 changes: 0 additions & 4 deletions lms/djangoapps/discussion/rest_api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,3 @@ def test_filter(self):
filter_spam_urls_from_html('<div>example.com/abc/def</div>')[0],
'<div></div>'
)
self.assertEqual(
filter_spam_urls_from_html('<div>e x a m p l e . c o m / a b c / d e f</div>')[0],
'<div></div>'
)
Loading