Skip to content

Commit

Permalink
Exclude example.com from URL regex
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-daniels committed Apr 29, 2015
1 parent 64cefb2 commit 60f847d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion findspam.py
Expand Up @@ -113,7 +113,7 @@ class FindSpam:
{'regex': u"(?i)\\b(crap)\\b", 'all': True, 'sites': [], 'reason': "Offensive {} detected", 'insensitive': True, 'title': True, 'body': False, 'username': False, 'stripcodeblocks': False, 'body_summary': False},
{'regex': ur"^(?=.*\p{upper})\P{lower}*$", 'all': True, 'sites': [], 'reason': "All-caps title", 'title': True, 'body': False, 'username': False, 'stripcodeblocks': False, 'body_summary': False},
{'regex': u"^(?=.*[0-9])[^\\pL]*$", 'all': True, 'sites': [], 'reason': "Numbers-only title", 'title': True, 'body': False, 'username': False, 'stripcodeblocks': False, 'body_summary': False},
{'regex': u"https?://[a-zA-Z0-9_.-]+\\.[a-zA-Z]{2,4}(/[a-zA-Z0-9_/?=.-])?", 'all': True,
{'regex': u"https?://(?!(www\.)?example\.com)[a-zA-Z0-9_.-]+\\.[a-zA-Z]{2,4}(/[a-zA-Z0-9_/?=.-])?", 'all': True,
'sites': ["stackoverflow.com", "superuser.com", "askubuntu.com"], 'reason': "URL in title", 'title': True, 'body': False, 'username': False, 'stripcodeblocks': False, 'body_summary': False},
{'regex': u"(?i)(%s)" % "|".join(blacklisted_websites), 'all': True,
'sites': [], 'reason': "Blacklisted website", 'title': True, 'body': True, 'username': True, 'stripcodeblocks': False, 'body_summary': True},
Expand Down
4 changes: 3 additions & 1 deletion test/test_regexes.py
Expand Up @@ -61,7 +61,9 @@
('something', 'his email address is (SOMEONE@GMAIL.COM)', '', 'stackoverflow.com', False, False),
('something', 'URL: &email=someone@gmail.com', '', 'meta.stackexchange.com', False, False),
('random title', 'URL: page.html#someone@gmail.com', '', 'rpg.stackexchange.com', False, False),
(u'Как рандомно получать числа 1 и 2?', 'Body here', u'Сашка', 'ru.stackoverflow.com', False, False)
(u'Как рандомно получать числа 1 и 2?', 'Body here', u'Сашка', 'ru.stackoverflow.com', False, False),
('Should not be caught: http://example.com', '', '', 'drupal.stackexchange.com', False, False),
('Should not be caught: https://www.example.com', '', '', 'drupal.stackexchange.com', False, False)
])
def test_regexes(title, body, username, site, body_is_summary, match):
# If we want to test answers separately, this should be changed
Expand Down

0 comments on commit 60f847d

Please sign in to comment.