3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-09 05:29:33 +01:00
pbot/PBot/Utils/SafeFilename.pm

26 lines
390 B
Perl
Raw Normal View History

2017-09-05 04:06:31 +02:00
package PBot::Utils::SafeFilename;
use 5.010; use warnings;
require Exporter;
our @ISA = qw/Exporter/;
our @EXPORT = qw/safe_filename/;
sub safe_filename {
my $name = shift;
my $safe = '';
while ($name =~ m/(.)/gms) {
if ($1 eq '&') {
$safe .= '&';
} elsif ($1 eq '/') {
$safe .= '&fslash;';
} else {
$safe .= $1;
}
}
return $safe;
}
1;