Ignore:
Timestamp:
2004-10-12T10:51:13+13:00 (20 years ago)
Author:
jrm21
Message:

sanity check for a valid date before trying to add it as metadata, otherwise
there might be uninitialised variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/PDFPlug.pm

    r8227 r8278  
    219219
    220220    # We're just interested in the date bit, not the time
    221     $datemeta =~ /(\d\d\d\d)-(\d\d)-(\d\d).*/;
    222     $doc_obj->add_utf8_metadata($cursection, "Date", "$1$2$3");
     221    # some pdf creators (eg "Acrobat 5.0 Scan Plug-in for Windows")
     222    # set a /CreationDate, and set /ModDate to 000000000. pdftohtml
     223    # extracts the ModDate, so it is 0...
     224    $datemeta =~ /(\d+)-(\d+)-(\d+)/;
     225    my ($year, $month, $day) = ($1,$2,$3);
     226    if (defined($year) && defined($month) && defined($day)) {
     227        if ($year == 0) {next}
     228        if ($year < 100) {$year += 1900} # just to be safe
     229        if ($month =~ /^\d$/) {$month="0$month"} # single digit
     230        if ($day =~ /^\d$/) {$day="0$day"} # single digit
     231        my $date="$year$month$day";
     232        $doc_obj->add_utf8_metadata($cursection, "Date", $date);
     233    }
    223234    }
    224235
Note: See TracChangeset for help on using the changeset viewer.