mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Escape the text, avoid parse problems
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from hr.app_defines import *
|
from hr.app_defines import *
|
||||||
from hr.models import Blacklist, Application
|
from hr.models import Blacklist, Application
|
||||||
@@ -43,19 +45,19 @@ def blacklist_values(user):
|
|||||||
evechars = EVEPlayerCharacter.objects.filter(eveaccount__user=user).select_related('corporation', 'corporation__alliance')
|
evechars = EVEPlayerCharacter.objects.filter(eveaccount__user=user).select_related('corporation', 'corporation__alliance')
|
||||||
|
|
||||||
# Check Character blacklists
|
# Check Character blacklists
|
||||||
characters = evechars.values_list('name', flat=True)
|
characters = [re.escape(x) for x in evechars.values_list('name', flat=True)]
|
||||||
if len(characters):
|
if len(characters):
|
||||||
objs = bl_items.filter(type=BLACKLIST_TYPE_CHARACTER, value__iregex=r'(' + '|'.join(characters) + ')')
|
objs = bl_items.filter(type=BLACKLIST_TYPE_CHARACTER, value__iregex=r'(' + '|'.join(characters) + ')')
|
||||||
blacklist.extend(objs)
|
blacklist.extend(objs)
|
||||||
|
|
||||||
# Check Corporation blacklists
|
# Check Corporation blacklists
|
||||||
corporations = evechars.values_list('corporation__name', flat=True)
|
corporations = [re.escape(x) for x in evechars.values_list('corporation__name', flat=True)]
|
||||||
if len(corporations):
|
if len(corporations):
|
||||||
objs = bl_items.filter(type=BLACKLIST_TYPE_CORPORATION, value__iregex=r'(' + '|'.join(corporations) + ')')
|
objs = bl_items.filter(type=BLACKLIST_TYPE_CORPORATION, value__iregex=r'(' + '|'.join(corporations) + ')')
|
||||||
blacklist.extend(objs)
|
blacklist.extend(objs)
|
||||||
|
|
||||||
# Check Alliance blacklists
|
# Check Alliance blacklists
|
||||||
alliances = [x for x in evechars.values_list('corporation__alliance__name', flat=True) if x]
|
alliances = [re.escape(x) for x in evechars.values_list('corporation__alliance__name', flat=True) if x]
|
||||||
if len(alliances):
|
if len(alliances):
|
||||||
objs = bl_items.filter(type=BLACKLIST_TYPE_ALLIANCE, value__iregex=r'(' + '|'.join([x for x in alliances if x]) + ')')
|
objs = bl_items.filter(type=BLACKLIST_TYPE_ALLIANCE, value__iregex=r'(' + '|'.join([x for x in alliances if x]) + ')')
|
||||||
blacklist.extend(objs)
|
blacklist.extend(objs)
|
||||||
|
|||||||
Reference in New Issue
Block a user