From 05de5991fa0518c284aea267564128c64f193a7c Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Wed, 30 Jun 2021 04:14:52 +0200 Subject: Add url validator for incomming strings --- rwa/support/sessionservice/service.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'rwa') diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index eb588ae..bdd8fbe 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -36,6 +36,7 @@ import dbus import dbus.mainloop.glib import dbus.service from gi.repository import GLib +import validators from .config import user_settings from .lock import is_locked, lock, unlock @@ -77,6 +78,16 @@ class RWASupportSessionService(dbus.service.Object): logging.info("D-Bus service has been started.") + def _is_url(self, url: str) -> bool: + """Test if the given string contains an url. + + :param url: The string which should be an URL. + :return: Bool (True=is url) or (False=no url) + """ + valid = validators.url(url) + logging.debug('is url?: "%s": %s', url, valid) + return valid + def _get_web_app_hosts(self) -> str: """Get all registered RWA.Support.WebApp hosts. -- cgit v1.2.3