Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Preventing XSS (sg)

by tye (Sage)
on Sep 19, 2007 at 20:48 UTC ( [id://639996]=note: print w/replies, xml ) Need Help??


in reply to Re: Preventing XSS
in thread Preventing XSS

Note that I see no reason to encode quote characters here. It isn't like the result is being placed into an attribute value. (:

And I probably wouldn't encode all ampersands since they are useful and rather low risk. If you are worried about the little-supported javascriptish ampersand stuff, then I'd only encode those ampersands. But I guess taking something useful away from users out of combined fear and laziness is not a shockingly rare result.

Which leaves us with a couple of simple regexes and little reason to use a module:

s/&{/&amp;{/g; s/</&lt;/g;

- tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://639996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found