content path overrides: allow single dots and enforce max-lengths
Allow a dot as long as its not followed by another dot and enforce max component and (a reduced) max path length checking already at schema level. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -355,9 +355,15 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override);
|
|||||||
sub verify_dir_override {
|
sub verify_dir_override {
|
||||||
my ($value, $noerr) = @_;
|
my ($value, $noerr) = @_;
|
||||||
|
|
||||||
if ($value =~ m/^([a-z]+)=[^.]+$/ && verify_content($1, $noerr)) {
|
if ($value =~ m/^([a-z]+)=([^.]*(?:\.?[^.]+)+)$/) {
|
||||||
|
my ($content_type, $relative_path) = ($1, $2);
|
||||||
|
if (verify_content($content_type, $noerr)) {
|
||||||
|
# linux has 4k max-path, but limit total length to lower as its concat'd for full path
|
||||||
|
if (length($relative_path) < 1023 && !(grep { length($_) >= 255 } split('/', $relative_path))) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return undef if $noerr;
|
return undef if $noerr;
|
||||||
die "invalid override '$value'\n";
|
die "invalid override '$value'\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user