2021-03-17 11:07:19 -04:00
|
|
|
package Hydra::Helper::Escape;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use base qw(Exporter);
|
2021-03-17 11:53:00 -04:00
|
|
|
use Hydra::Helper::AttributeSet;
|
2021-03-17 11:07:19 -04:00
|
|
|
|
2021-03-17 11:53:00 -04:00
|
|
|
our @EXPORT = qw(escapeString escapeAttributePath);
|
2021-03-17 11:07:19 -04:00
|
|
|
|
|
|
|
sub escapeString {
|
|
|
|
my ($s) = @_;
|
|
|
|
$s =~ s|\\|\\\\|g;
|
|
|
|
$s =~ s|\"|\\\"|g;
|
|
|
|
$s =~ s|\$|\\\$|g;
|
|
|
|
return "\"" . $s . "\"";
|
|
|
|
}
|
2021-03-17 11:53:00 -04:00
|
|
|
|
|
|
|
sub escapeAttributePath {
|
|
|
|
my ($s) = @_;
|
|
|
|
|
|
|
|
return join(".", map( { escapeString($_) } Hydra::Helper::AttributeSet::splitPath($s)));
|
|
|
|
}
|