Page 1 of 1

function getid3_write_id3v2::IsValidURL() too restrictive

Posted: Wed Jun 08, 2016 6:32 pm
by fred727
version: 1.9.12
php: 7

1) Don't allow new hostnames with extentions > 3 characters. (an so, don't allow hostnames like "localhost" or "x.localhost" for test...)
2) Don't allow character "," or "%" in path... Realy too restrictive here.

---> So it is impossible to use such URL in mp3 id3v2.3 tags (W???, etc...)

I replaced this function by this one (I think control must be done before user called the library, not by the library itself) :

Code: Select all

	public function IsValidURL($url, $allowUserPass=false) {
		return (bool) $url;
	}

PS: it would be nicer if this fonction was static ;)

Re: function getid3_write_id3v2::IsValidURL() too restrictiv

Posted: Wed Jun 08, 2016 6:43 pm
by James Heinrich
It would be good to have perfect URL validation, but for now I have relaxed the validation checks. Not quite as much as your example, but it shouldn't reject any valid URL.
https://github.com/JamesHeinrich/getID3 ... 6590d6175c

Re: function getid3_write_id3v2::IsValidURL() too restrictiv

Posted: Wed Jun 08, 2016 7:02 pm
by fred727
Perfect !

If you want to test a minimum, you could use this regexp I think. But your solution is OK.

Code: Select all

preg_match('#^([a-z][a-z0-9]*)://[^ ]+$#i', $url)