1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 08:00:00 +00:00
This commit is contained in:
sharkykh 2017-05-14 16:47:18 +03:00 committed by Kfir Hadas
parent 60b7029fcc
commit 9ac56ba3d7

View file

@ -223,7 +223,6 @@ class UploadForm(FlaskForm):
except AssertionError as e:
raise ValidationError('Malformed torrent metadata ({})'.format(e.args[0]))
site_tracker = app.config.get('MAIN_ANNOUNCE_URL')
ensure_tracker = app.config.get('ENFORCE_MAIN_ANNOUNCE_URL')
@ -235,11 +234,12 @@ class UploadForm(FlaskForm):
# Ensure private torrents are using our tracker
if torrent_dict['info'].get('private') == 1:
if torrent_dict['announce'].decode('utf-8') != site_tracker:
raise ValidationError('Private torrent: please set {} as the main tracker'.format(site_tracker))
raise ValidationError(
'Private torrent: please set {} as the main tracker'.format(site_tracker))
elif ensure_tracker and not tracker_found:
raise ValidationError('Please include {} in the trackers of the torrent'.format(site_tracker))
raise ValidationError(
'Please include {} in the trackers of the torrent'.format(site_tracker))
# Note! bencode will sort dict keys, as per the spec
# This may result in a different hash if the uploaded torrent does not match the
@ -273,7 +273,8 @@ def _validate_trackers(torrent_dict, tracker_to_check_for=None):
announce = torrent_dict.get('announce')
announce_string = _validate_bytes(announce, 'announce', 'utf-8')
tracker_found = tracker_to_check_for and (announce_string.lower() == tracker_to_check_for.lower()) or False
tracker_found = tracker_to_check_for and (
announce_string.lower() == tracker_to_check_for.lower()) or False
announce_list = torrent_dict.get('announce-list')
if announce_list is not None: