From dfdd96bcad15ed258cc35e50020eca6432889bad Mon Sep 17 00:00:00 2001 From: ManiruzzamanAkash Date: Sat, 6 Nov 2021 10:33:51 +0600 Subject: [PATCH] Added related function for url sanitization --- src/functions.php | 157 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 src/functions.php diff --git a/src/functions.php b/src/functions.php new file mode 100644 index 0000000..3251e5e --- /dev/null +++ b/src/functions.php @@ -0,0 +1,157 @@ + 'scheme', + PHP_URL_HOST => 'host', + PHP_URL_PORT => 'port', + PHP_URL_USER => 'user', + PHP_URL_PASS => 'pass', + PHP_URL_PATH => 'path', + PHP_URL_QUERY => 'query', + PHP_URL_FRAGMENT => 'fragment', + ); + + if (isset($translation[$constant])) { + return $translation[$constant]; + } else { + return false; + } +} + +/** + * Get allowed protocols for URLs. + * + * @since 0.0.2 + * + * @return array Array of allowed protocols. + */ +function get_allowed_protocols() +{ + return array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'irc6', 'ircs', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'sms', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn'); +}