Skip to content

Commit b8a3dff

Browse files
committed
Avoid single quotes in the invalid account request messages since it will break
when injected in the javascript dialogs on migadmin.
1 parent 07f68c4 commit b8a3dff

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

mig/shared/accountreq.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,26 +1187,28 @@ def existing_user_collision(configuration, raw_request, client_id):
11871187
(_, hits) = search_users(search_filter, configuration, db_path)
11881188
collisions = [user_id for (user_id, _) in hits if user_id != client_id]
11891189
if collisions:
1190-
logger.warning('one or more ID collisions in request from %r: %s' % \
1190+
logger.warning('one or more ID collisions in request from %r: %s' %
11911191
(client_id, ', '.join(collisions)))
11921192
return True
11931193
else:
11941194
return False
11951195

1196+
11961197
def early_validation_checks(configuration, raw_request, service, username,
11971198
password):
11981199
"""Early validation checks including e.g. password check when change is not
11991200
authorized. Useful to allow janitor to request invalid requests with
12001201
sufficient delay to render various user enumeration, email and password
12011202
guessing scenarios infeasible"""
12021203
logger = configuration.logger
1204+
# NOTE: carefully avoid single quotes in text here to avoid js quote errors
12031205
illegal_pw_change = """invalid password in renewal request.
12041206
Please use your existing password when renewing to prove account ownership. You
1205-
can use the 'Forgot password' link on the login page to securely reset it first
1207+
can use the *Forgot your password?* link on the login page to securely reset it first
12061208
if needed"""
12071209
renewal_blocked = """account status blocks renewal request.
1208-
Please contact support if you haven't been informed why this might be and think
1209-
your account access should be renewed"""
1210+
Please contact support if you have not been informed why this might be and
1211+
think your account access should be renewed"""
12101212
id_collision = """invalid ID in account creation request.
12111213
An existing user has overlapping but not identical ID fields. You must reuse
12121214
your exact existing ID to renew account access. Please contact support if you
@@ -1234,11 +1236,11 @@ def early_validation_checks(configuration, raw_request, service, username,
12341236
hashed = user_dict.get('password_hash', None)
12351237
if not check_hash(configuration, service, username, password,
12361238
hashed):
1237-
logger.warning('illegal password change in request from %r' % \
1239+
logger.warning('illegal password change in request from %r' %
12381240
client_id)
12391241
raw_request['invalid'].append(illegal_pw_change)
12401242
elif account_status not in ('temporal', 'active', 'inactive'):
1241-
logger.warning('existing account for %r is %s and not renewable' \
1243+
logger.warning('existing account for %r is %s and not renewable'
12421244
% (client_id, account_status))
12431245
raw_request['invalid'].append(renewal_blocked)
12441246
else:
@@ -1253,16 +1255,16 @@ def early_validation_checks(configuration, raw_request, service, username,
12531255
peers_email = raw_request.get('peers_email', None)
12541256
full_name = raw_request.get('full_name', 'UNSET')
12551257
if configuration.site_enable_peers and \
1256-
('email' in configuration.site_peers_explicit_fields and \
1257-
not peers_email or \
1258-
'full_name' in configuration.site_peers_explicit_fields and \
1259-
not peers_full_name):
1260-
logger.warning('missing peers field in request from %r: %r %r' % \
1258+
('email' in configuration.site_peers_explicit_fields and
1259+
not peers_email or
1260+
'full_name' in configuration.site_peers_explicit_fields and
1261+
not peers_full_name):
1262+
logger.warning('missing peers field in request from %r: %r %r' %
12611263
(client_id, peers_full_name, peers_email))
12621264
raw_request['invalid'].append(missing_peers_info)
12631265
elif len(full_name.split(' ')) < 2:
12641266
# TODO: prevent this at the source instead - sign up and peers
1265-
logger.warning('invalid single word full name in request from %r' \
1267+
logger.warning('invalid single word full name in request from %r'
12661268
% client_id)
12671269
raw_request['invalid'].append(invalid_full_name)
12681270
# TODO: check that specified peers have accounts and can act as peers

0 commit comments

Comments
 (0)