mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
0120c24927
commit
b67890d15d
3 changed files with 30 additions and 0 deletions
|
|
@ -441,3 +441,18 @@ def filters_should_redirect(special_args):
|
|||
('_filter_value_{}'.format(number), None),
|
||||
])
|
||||
return redirect_params
|
||||
|
||||
|
||||
whitespace_re = re.compile(r'\s')
|
||||
|
||||
|
||||
def is_url(value):
|
||||
"Must start with http:// or https:// and contain JUST a URL"
|
||||
if not isinstance(value, str):
|
||||
return False
|
||||
if not value.startswith('http://') and not value.startswith('https://'):
|
||||
return False
|
||||
# Any whitespace at all is invalid
|
||||
if whitespace_re.search(value):
|
||||
return False
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue