Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Escaping special characters

by aitap (Curate)
on Aug 12, 2015 at 08:42 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2023-03-22 03:29 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.