[pve-devel] [PATCH storage v2] dirplugin: fix #3986: check for trailing slashes

Daniel Herzig d.herzig at proxmox.com
Fri Nov 22 17:35:26 CET 2024


Thomas Lamprecht <t.lamprecht at proxmox.com> writes:

> Am 22.11.24 um 14:13 schrieb Daniel Herzig:
>> diff --git a/src/PVE/Storage/DirPlugin.pm b/src/PVE/Storage/DirPlugin.pm
>> index fb23e0a..c72c321 100644
>> --- a/src/PVE/Storage/DirPlugin.pm
>> +++ b/src/PVE/Storage/DirPlugin.pm
>> @@ -245,6 +245,8 @@ sub check_config {
>>      if ($opts->{path} !~ m|^/[-/a-zA-Z0-9_.@]+$|) {
>>  	die "illegal path for directory storage: $opts->{path}\n";
>>      }
>> +    # remove trailing slashes from path
>> +    $opts->{path} =~ s|(.*[^/])/+$|$1|;
>
> If we want to use the always available File::Spec module, like Max wanted to
> in a recent series, this could be changed to
>
> $opts->{path} = File::Spec->canonpath($opts->{path});
>
Thanks! Well, this would look the cleanest to me, I did not have this module on my
radar yet.

Will use it in v3!
>>      return $opts;
>>  }
>>  




More information about the pve-devel mailing list