in reply to Re: Escaping special characters
in thread Escaping special characters

james28909,AnomalousMonk thank you for sharing your thoughts. The methods that you have introduced can be used to escape the HTML metacharacter !. If I escaped the metacharacter ! for perl, using the code below,

$input =~ s/!/\!/g;

would it cancel out the effects of the method that you have introduced? Or is it enough to escape the HTML metacharacter ! and not to do anything with the perl metacharacter !? would that be secure enough as not to cause any malicious scripting by the user?

Replies are listed 'Best First'.
Re^3: Escaping special characters
by james28909 (Deacon) on Aug 12, 2015 at 05:05 UTC
    I personally do not see an exclamation point in Metacharacters but if your just trying to remove the '!' from user input, whether it be Perl or HTML, please take this into consideration:
    use strict; use warnings; while (<DATA>){ print "Perl string - ", my $perl_string = $_ =~ s/!//rg if $_ !~ /<.*? +>/g; print "HTML string - ", my $html_string = $_ =~ s/!//rg if $_ =~ /<.*? +>/g; } __DATA__ 123!!!!!! <p>123!!!!!</p>
    As for the security of your website, I think I will leave that to some professionals ;) Update: Changed link, thanks soonix