Acme-Addslashes
view release on metacpan or search on metacpan
lib/Acme/Addslashes.pm view on Meta::CPAN
=cut
use v5.12;
use strict; # lolwut? strict??
use Encode qw(encode);
use feature qw(unicode_strings);
use parent "Exporter";
our @EXPORT_OK = qw(addslashes);
our $VERSION = '0.1.3';
=head1 FUNCTIONS
=head2 addslashes
my $totally_safe_string = addslashes("Robert'); DROP TABLE Students;--");
The only function exported by this module. Will literally add slashes to anything.
Letters, numbers, punctuation, whitespace, unicode symbols.
You name it, this function can add a slash to it.
Will return you a C<utf8> encoded string containing your original string, but with
enough slashes added to make Freddy Krueger jealous.
=cut
# The addslashes function. It is documented above. -- JAITKEN
sub addslashes {
# Get the arguments passed to the function using the shift command -- JAITKEN
my $unsafe_string = shift;
# Split the string into letters - just like explode in PHP. Or maybe str_split
# I can't remember which one is which -- JAITKEN
my @unsafe_array = split('', $unsafe_string);
# Add slashes to every character thanks to unicode.
# This is complex magic -- JAITKEN
# I think these slashes could be longer -- SKINGTON
# You forgot the last slash -- JAITKEN
my $safe_string = join("\N{U+0338}", @unsafe_array) . "\N{U+0338}";
# Return the safe string using the return function of PERL -- JAITKEN
return encode("utf8", $safe_string);
}
# The end of the module. -- JAITKEN
1;
=head1 AUTHOR
James Aitken <jaitken@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by James Aitken.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.598 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )