hi,My regex skills are serious lacking and after scouring the net for relevant links I'm a bit stuck. I've got a textarea field where I pull user input from, and I'd like to search this entire field for a Windows Directory Path (ex. C:\Documents\Blah).
Basically my users are allowed to specify HTML img tags in this textarea and I'd like to make sure that they don't reference any images that are on their local hard drive (which many of them are doing and then thinking the HTML that I generate from that actually works when it doesn't).
Suggestions?
i would start like this:
1. get the entire src-param of your img tag:
<?php $regex = '/src="([^"])"/'; ?>
this should search for everything between the two doubleqoutes and give it as $match[1] if working with this param in preg_match().
2. check this string for url or local path:
some possibilities are, to check for backslashes, as they are only allowed in win-paths, not in url. or to check whether your path starts with a letter, followed by a colon ('/[a-zA-Z]:/') as the local root (drive letter). if both is false assume that it's a relative or absolute url.
the other (better?) way is, to check generally, whether it's a valid url according to rfc1738 (a local win-path isn't). maybe there are existing functions?
hth SVEN
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php