Image

Imageneophoenix wrote in Imagephp feeling really stoopid

RegEx Help - Updated

Hey everyone!

Rather than going through the replies to the post earlier I decided to create a new post to further explain myself. From time to time I get kinda wrapped up in the details of coding something and usually end up trying to explain concepts to non-technical people through abstract terms. For some reason I was in that frame of mind when I posted to this group. Basically, I am *very* guilty of under-estimating the level of understanding of the php group. What I should have said is this:

In php, the strip_tags() function works ok, but it ignores the attributes of the allowed tags which leaves it open to things like this:
<i onmouseover="window.open('http://www.goatse.cx');">Ha Ha!</i>


What I was trying to do was to write a more robust version of the strip_tags() function that would also allow you to declare allowable attributes (such as "href" for and anchor tags).

So, restated, what I'm trying to do is take a string like
<img src="http://www.somewhere.com/something.jpg" 
onmouseover="window.open('http://www.goatse.cx');" height="1000px" style="height: 1000px;" />


and remove EVERYTHING but this:
<img src="http://www.somewhere.com/something.jpg" />


I apologize for the totally brain-dead way in which I stated the original question and I promise to think (more) before I post. It's just that trying to explain this concept to some of the non-geeks that I work with kinda got stuck in my brain.

/me puts on asbestos suit and ducks