3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-11 12:32:37 +01:00

Add SafeFilename module

This commit is contained in:
Pragmatic Software 2017-09-04 19:06:31 -07:00
parent ba6cfdca92
commit 5e6e5cb21d

View File

@ -0,0 +1,25 @@
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;