/usr/share/doc/libsvn-hooks-perl/examples/check-valid-utf8.pl is in libsvn-hooks-perl 1.27-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Check if every changed text file contains valid UTF-8 data.
PRE_COMMIT {
my ($svnlook) = @_;
foreach my $file ($svnlook->added(), $svnlook->updated()) {
next if $file =~ m:/$:; # skip directories
my $props = $svnlook->proplist($file);
next unless exists $props->{'svn:mime-type'}; # skip files without a mime-type
next unless $props->{'svn:mime-type'} =~ m:^text/:; # skip non-text files
# Try to decode file contents as UTF-8 and dies if not
require Encode;
eval {Encode::decode_utf8($svnlook->cat($file), Encode::FB_CROAK)};
die "New file '$file' does not contain valid UTF-8 data: $@\n" if $@;
}
};
1;
|