[bug in valid_url ?] url with specials chars not filtered
Hello world, Here's my first question (Drupal 5.3) : some of my input text fields contains urls like : - http://collab.sakaiproject.org/portal/site/!gateway/page/!gateway-100 or - http://www.mediawiki.org/wiki/Manual:Configuration_settings_(alphabetical) This url are not converted like others in url (i suppose because some "!" and "(" are part of them). I found that http://api.drupal.org/api/function/valid_url/5 may be incomplete for some regular, W3C and RFCs valid chars : ------- function valid_url($url, $absolute = FALSE) { $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+]'; if ($absolute) { return preg_match("/^(http|https|ftp):\/\/". $allowed_characters ."+$/i", $url); } else { return preg_match("/^". $allowed_characters ."+$/i", $url); } } ------------- Same thing for http://api.drupal.org/api/function/_filter_url/5 I'm quite surprised of that... Found some pseudo patches on the web (like http://amadain.net/node?page=2 ) but I I'm curious to know what some regular signs are not added to the regex.... Is it a bug or a feature ? If it's a bug (I think that someone else must have already noticed that behavior) should I report it ? By the way, I tried to complete the regex by moifying $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+]'; with $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+!\(\)]'; and same in _filter_url function, but it doesn't seems to work... :-( Any Idea why ? cheers Pierre-Yves
participants (1)
-
pyg