When a user uploads a photo for their profile, I allow them to add an optional Photo Label like this...
Sam's Spiral GIF
To prevent against XSS attacks, I wrapped the Photo Label with htmlentities like this...
PHP Code:title='" . htmlentities($photoLabel) . "' />
The problem is that when I hover over the user's photo, I see this...
(I added spaces above because it keeps getting converted by SitePoint?!)Sam & #039 ; s Spiral GIF
How can I use htmlentities() and get my output to look proper?
Thanks,
Debbie



Reply With Quote




It can be easy to mix them up. In languages such as PHP and JavaScript, a backslash escapes special characters. But in HTML, the backslash has no special meaning at all.

Bookmarks