mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-07 22:29:19 +00:00
fhem.pl: escapeLogLine patch from Boris
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@5237 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
374e77fccb
commit
f28df1db90
8
fhem.pl
8
fhem.pl
@ -3739,15 +3739,21 @@ utf8ToLatin1($)
|
|||||||
sub escapeLogLine($) {
|
sub escapeLogLine($) {
|
||||||
my ($s)= @_;
|
my ($s)= @_;
|
||||||
|
|
||||||
|
# http://perldoc.perl.org/perlrebackslash.html
|
||||||
my %escSequences = (
|
my %escSequences = (
|
||||||
'\t' => "\\t",
|
'\a' => "\\a",
|
||||||
|
'\e' => "\\e",
|
||||||
|
'\f' => "\\f",
|
||||||
'\n' => "\\n",
|
'\n' => "\\n",
|
||||||
'\r' => "\\r",
|
'\r' => "\\r",
|
||||||
|
'\t' => "\\t",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$s =~ s/\\/\\\\/g;
|
||||||
foreach my $regex (keys %escSequences) {
|
foreach my $regex (keys %escSequences) {
|
||||||
$s =~ s/$regex/$escSequences{$regex}/g;
|
$s =~ s/$regex/$escSequences{$regex}/g;
|
||||||
}
|
}
|
||||||
|
$s =~ s/([\000-\037])/sprintf("\\%03o", ord($1))/eg;
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user