noexcal Posted March 5, 2008 Share Posted March 5, 2008 I need to replace invalid img tags on submit. PHP will preg_replace <img src="http://somesite.com/script.php"> but will allow <img src="http://somesite.com/image.gif"> something like $field = preg_replace('!\<img(.*)src=\"^(http|https)\:\/\/(.*)\"(.*)\.^(jpg|gif|jpeg|png)(.*)\>!i', '..', $field); That does not work, but you get the main idea. I do not need some long code, I know this can be done simple, because I have done similar stuff.. For some reason I just get stuck on this one. Quote Link to comment Share on other sites More sharing options...
effigy Posted March 5, 2008 Share Posted March 5, 2008 I need to replace invalid img tags on submit. What are "invalid img tags"? Quote Link to comment Share on other sites More sharing options...
noexcal Posted March 7, 2008 Author Share Posted March 7, 2008 oh sorry, xss attacks such as were used to attack myspace. <img src="http://site.com/deleteuser?task=dodelete"> stuff like that. I only want to allow img tags that are gif jpg jpeg png Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.