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
2 changes: 1 addition & 1 deletion osf/external/spam/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

DOMAIN_REGEX = re.compile(r'\W*(?P<protocol>\w+://)?(?P<www>www\.)?(?P<domain>([\w-]+\.)+[a-zA-Z]+)(?P<path>[/\-\.\w]*)?\W*')
REDIRECT_CODES = {301, 302, 303, 307, 308}
NOTABLE_POST_NOMINALS = ['m.sc.', 'msc.', 'b.sc.', 'bsc.', 'd.sc.', 'dsc.', 'phd.', 'ph.d.', 'msc.pt', 'pt.', 'prof.', 'dr.', 'md.', 'jd.', 'esq.']
NOTABLE_POST_NOMINALS = ['m.sc', 'm.sc.', 'msc.', 'b.sc.', 'bsc.', 'd.sc.', 'dsc.', 'phd.', 'ph.d.', 'msc.pt', 'pt.', 'prof.', 'dr.', 'md.', 'jd.', 'esq.']

@celery_app.task()
def reclassify_domain_references(notable_domain_id, current_note, previous_note):
Expand Down
6 changes: 4 additions & 2 deletions osf/models/validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import waffle
from django.db.models import Q
from django.db.models.functions import Lower
from jsonschema import ValidationError as JsonSchemaValidationError, SchemaError, Draft7Validator, validate, validators
from django.conf import settings
from django.core.validators import URLValidator, validate_email as django_validate_email
Expand Down Expand Up @@ -121,12 +122,13 @@ def has_domain_in_user_fields_for_names(fullname):
Q(note=NotableDomain.Note.ASSUME_HAM_UNTIL_REPORTED) |
Q(note=NotableDomain.Note.IGNORED)
)
.values_list('domain', flat=True)
.annotate(domain_lower=Lower('domain'))
.values_list('domain_lower', flat=True)
.distinct()
)
for match in DOMAIN_REGEX.finditer(fullname):
domain = match.group('domain')
if domain in notable_domain_list:
if domain.lower() in notable_domain_list:
continue
if looks_like_url(match):
return True
Expand Down
1 change: 1 addition & 0 deletions osf_tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_validate_expand_subject_hierarchy():
'fullname',
[
'Judith Sarah Preuss, M.Sc.',
'Judith Sarah Preuss, M.Sc',
'J.H. van Hateren',
'Sami-Egil Ahonen',
'Giovanni Luca Ciampaglia',
Expand Down