[Git][reproducible-builds/strip-nondeterminism][master] Support timestamp clamping of "tIME" chunks in .png files. (Closes: #7)
Chris Lamb
gitlab at salsa.debian.org
Thu Jun 27 09:56:05 UTC 2019
Chris Lamb pushed to branch master at Reproducible Builds / strip-nondeterminism
Commits:
849f8516 by Chris Lamb at 2019-06-27T09:55:46Z
Support timestamp clamping of "tIME" chunks in .png files. (Closes: #7)
- - - - -
3 changed files:
- lib/File/StripNondeterminism/handlers/png.pm
- + t/fixtures/png/bug_931039.png.in
- + t/fixtures/png/bug_931039.png.out
Changes:
=====================================
lib/File/StripNondeterminism/handlers/png.pm
=====================================
@@ -29,6 +29,7 @@ use File::StripNondeterminism::Common qw(copy_data);
use File::Basename qw/dirname/;
use POSIX qw/strftime/;
use List::Util qw/min/;
+use Time::Local qw/timegm/;
sub crc($) {
my ($data) = @_;
@@ -47,6 +48,12 @@ sub time_chunk($) {
pack('nCCCCC', 1900+$year, $mon+1, $mday, $hour, $min, $sec));
}
+sub parse_time_chunk($) {
+ my ($data) = @_;
+ my ($year, $mon, $mday, $hour, $min, $sec) = unpack('nCCCCC', $data);
+ return timegm($sec, $min, $hour, $mday, $mon, $year);
+}
+
sub text_chunk($$) {
my ($keyword, $data) = @_;
return chunk('tEXt', pack('Z*a*', $keyword, $data));
@@ -103,9 +110,12 @@ sub _normalize {
}
if ($type eq "tIME") {
- print $tempfile time_chunk($canonical_time)
- if defined($canonical_time);
$modified = 1;
+ next if not defined $canonical_time;
+ my $timestamp = $canonical_time;
+ $timestamp = min($timestamp, parse_time_chunk($data))
+ if $File::StripNondeterminism::clamp_time;
+ print $tempfile time_chunk($timestamp);
next;
} elsif (($type =~ /[tiz]EXt/)
&& ($data =~ /^(date:[^\0]+|Creation Time)\0/)) {
=====================================
t/fixtures/png/bug_931039.png.in
=====================================
Binary files /dev/null and b/t/fixtures/png/bug_931039.png.in differ
=====================================
t/fixtures/png/bug_931039.png.out
=====================================
Binary files /dev/null and b/t/fixtures/png/bug_931039.png.out differ
View it on GitLab: https://salsa.debian.org/reproducible-builds/strip-nondeterminism/commit/849f8516fc6e3b6da86290d4dd08d3dd2ddbd04c
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/strip-nondeterminism/commit/849f8516fc6e3b6da86290d4dd08d3dd2ddbd04c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190627/bb871b30/attachment.html>
More information about the rb-commits
mailing list