mirror of https://github.com/digint/btrbk
btrbk: check/sanitize leading/trailing whitespace on files
parent
77a39282de
commit
94a415e420
7
btrbk
7
btrbk
|
@ -3915,10 +3915,17 @@ sub check_file($$;@)
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
if($sanitize) {
|
if($sanitize) {
|
||||||
|
$file =~ s/^\s+//;
|
||||||
|
$file =~ s/\s+$//;
|
||||||
$file =~ s/\/(\.?\/)+/\//g; # sanitize "//", "/./" -> "/"
|
$file =~ s/\/(\.?\/)+/\//g; # sanitize "//", "/./" -> "/"
|
||||||
$file =~ s/\/\.$/\//; # sanitize trailing "/." -> "/"
|
$file =~ s/\/\.$/\//; # sanitize trailing "/." -> "/"
|
||||||
$file =~ s/\/$// unless($file eq '/'); # remove trailing slash
|
$file =~ s/\/$// unless($file eq '/'); # remove trailing slash
|
||||||
}
|
}
|
||||||
|
elsif(($file =~ /^\s/) || ($file =~ /\s$/)) {
|
||||||
|
ERROR "Illegal leading/trailing whitespace ${error_statement}: \"$file\"" if(defined($error_statement));
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue