Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Escaping special characters

by aitap (Curate)
on Aug 12, 2015 at 08:42 UTC ( [id://1138287]=note: print w/replies, xml ) Need Help??


in reply to Escaping special characters

to escape the occurrences of exclamation symbols (!) that will be supplied by the user so that they are not interpreted as part of the HTML and Perl code.
First of all, I'm not sure why do you need to escape exclamation symbols. Are you going to feed user input to an HTML browser, to the Perl interpeter, or both? On the one hand, ! does not have a special meaning in HTML, so when you feed text with !s to a browser, you can leave them unchanged (but run the input through a proper HTML escaping function from a well-tested CPAN module). On the other hand, to make ! have no special meaning (negation operator) in Perl (ETA: special meaning in Perl source code, not inside Perl strings), you'll have to quote it (!"!", but now you have to do something with a string) or to comment it out (!# !, Perl will completely ignore the comment). \! won't help: it's "return the reference to the result of negation", not "verbatim exclamation mark". And feeding untrusted user input to Perl is not a good thing to do anyway. Good thing that you can safely work with arbitrary strings without escaping them in Perl unless you eval them (or feed to shell, see also: perlsec, Safe) What exactly do you really need to do with $query->param('team_name')?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found