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. Link to comment https://forums.phpfreaks.com/topic/94443-regex-find-and-replace-invalid-img-tags/ 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"? Link to comment https://forums.phpfreaks.com/topic/94443-regex-find-and-replace-invalid-img-tags/#findComment-483884 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 Link to comment https://forums.phpfreaks.com/topic/94443-regex-find-and-replace-invalid-img-tags/#findComment-485849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.