mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
27 lines
421 B
Perl
27 lines
421 B
Perl
package PBot::Utils::SafeFilename;
|
|
use 5.010; use warnings;
|
|
use feature 'unicode_strings';
|
|
|
|
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;
|