* Escape string literals.[
This commit is contained in:
parent
7ffb32e048
commit
4d2cb75104
|
@ -5,6 +5,15 @@ use base qw/Catalyst::View/;
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
|
|
||||||
|
sub escape {
|
||||||
|
my ($s) = @_;
|
||||||
|
$s =~ s|\\|\\\\|g;
|
||||||
|
$s =~ s|\"|\\\"|g;
|
||||||
|
$s =~ s|\$|\\\$|g;
|
||||||
|
return "\"" . $s . "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
@ -14,15 +23,15 @@ sub process {
|
||||||
my $build = $c->stash->{nixPkgs}->{$name};
|
my $build = $c->stash->{nixPkgs}->{$name};
|
||||||
$res .= " # $name\n";
|
$res .= " # $name\n";
|
||||||
$res .= " { type = \"derivation\";\n";
|
$res .= " { type = \"derivation\";\n";
|
||||||
$res .= " name = \"" . ($build->resultInfo->releasename or $build->nixname) . "\";\n"; # !!! escaping?
|
$res .= " name = " . escape ($build->resultInfo->releasename or $build->nixname) . ";\n";
|
||||||
$res .= " system = \"" . $build->system . "\";\n"; # idem
|
$res .= " system = " . (escape $build->system) . ";\n";
|
||||||
$res .= " outPath = " . $build->outpath . ";\n";
|
$res .= " outPath = " . $build->outpath . ";\n";
|
||||||
$res .= " meta = {\n";
|
$res .= " meta = {\n";
|
||||||
$res .= " description = \"" . $build->description . "\";\n"
|
$res .= " description = " . (escape $build->description) . ";\n"
|
||||||
if $build->description;
|
if $build->description;
|
||||||
$res .= " longDescription = \"" . $build->longdescription . "\";\n"
|
$res .= " longDescription = " . (escape $build->longdescription) . ";\n"
|
||||||
if $build->longdescription;
|
if $build->longdescription;
|
||||||
$res .= " license = \"" . $build->license . "\";\n"
|
$res .= " license = " . (escape $build->license) . ";\n"
|
||||||
if $build->license;
|
if $build->license;
|
||||||
$res .= " };\n";
|
$res .= " };\n";
|
||||||
$res .= " }\n";
|
$res .= " }\n";
|
||||||
|
|
Loading…
Reference in a new issue