From: Leonardo Date: Mon, 7 Nov 2016 13:28:35 +0000 (+0100) Subject: bug 73: Add url validator in http_post_images X-Git-Tag: v1.0.2~13 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fopenvim.git;a=commitdiff_plain;h=2a5a0c5f6604a8dea29bcae20d9a1b2d00bdb8ff bug 73: Add url validator in http_post_images Signed-off-by: Leonardo --- diff --git a/httpserver.py b/httpserver.py index 88b1f0a..870d680 100644 --- a/httpserver.py +++ b/httpserver.py @@ -30,6 +30,7 @@ __author__="Alfonso Tierno" __date__ ="$10-jul-2014 12:07:15$" import bottle +import urlparse import yaml import json import threading @@ -451,6 +452,18 @@ def check_valid_uuid(uuid): except js_e.ValidationError: return False + +def is_url(url): + ''' + Check if string value is a well-wormed url + :param url: string url + :return: True if is a valid url, False if is not well-formed + ''' + + parsed_url = urlparse.urlparse(url) + return parsed_url + + @bottle.error(400) @bottle.error(401) @bottle.error(404) @@ -1091,6 +1104,8 @@ def http_post_images(tenant_id): image_file = http_content['image'].get('path',None) if os.path.exists(image_file): http_content['image']['checksum'] = md5(image_file) + elif is_url(image_file): + pass else: if not host_test_mode: content = "Image file not found"