Skip to content

Commit 5e8ab8f

Browse files
committed
PB-2205: using re.fullmatch() instead if re.match()
Using fullmatch() instead of match() only makes the service safer. This way, even if the regex is not anchored, map.geo.admin.ch.evil.com bypass trick will still be detected by the fullmatch and blocked. Otherwise the regex needs to be anchored.
1 parent 241be33 commit 5e8ab8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/helpers/url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def validate_url(url):
3232
logger.error('Invalid URL, could not determine the hostname, url=%s', url)
3333
abort(400, 'Invalid URL, could not determine the hostname')
3434

35-
if not re.match(ALLOWED_DOMAINS_PATTERN, result.hostname):
35+
if not re.fullmatch(ALLOWED_DOMAINS_PATTERN, result.hostname):
3636
logger.error('URL domain not allowed: %s', result.hostname)
3737
abort(400, 'URL domain not allowed')
3838

0 commit comments

Comments
 (0)