Currently the filter_xss_bad_protocol have a fixed list of allowed protocols. This does not allow modules to override the allowed protocols and reuse the function in their module. For e.g. I would like to check URLs in linkchecker module for validity, but I'd only like to allow http, https.

Currently the $allowed_protocols list is a static list in the Drupal settings. It would be great if the $allowed_protocols become an optional parameter for the function with a fall-back to the default list or otherwise if I'm able to specify the variable name where the allowed protocols of the module are defined. This would allow easier re-using of this function.

Something like:

  1. check_url($url, array('http', 'https'))
  2. check_url($url, 'linkchecker_allowed_protocols')
  3. filter_xss_bad_protocol($string, TRUE, array('http', 'https'))
  4. filter_xss_bad_protocol($string, TRUE, 'linkchecker_allowed_protocols')

Comments

sun.core’s picture

Version: 7.x-dev » 8.x-dev
dave reid’s picture

You could always do something like:

global $conf;

// Get the original/default value and save it.
$original = isset($conf['filter_allowed_protocols']) ? $conf['filter_allowed_protocols'] : array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'telnet', 'webcal');

// Override with our desired value
$conf['filter_allowed_protocols'] = array('http', 'https');

// Make the function call
filter_xss_bad_protocol($string, TRUE);

// Undo the override
$conf['filter_allowed_protocols'] = $original;
jhedstrom’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

This method was removed befor Drupal 7.