[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][lintian/lintian][master] Try to decode font file using utf8 if it fails with cp1252.



Title: GitLab

Louis-Philippe Véronneau pushed to branch master at lintian / lintian

Commits:

  • db373c08
    by Louis-Philippe Véronneau at 2025-09-08T13:19:36+00:00
    Try to decode font file using utf8 if it fails with cp1252.
    

1 changed file:

Changes:

  • lib/Lintian/Check/Fonts/Postscript/Type1.pm
    ... ... @@ -50,14 +50,24 @@ sub visit_installed_files {
    50 50
     
    
    51 51
         my @command = ('t1disasm', $item->unpacked_path);
    
    52 52
         my $bytes = safe_qx(@command);
    
    53
    +    my $enc_warning = 'In file ' . $item->name . $COLON . $SPACE;
    
    53 54
     
    
    54 55
         my $output;
    
    55 56
         try {
    
    56 57
             # iso-8859-1 works too, but the Font 1 standard could be older
    
    57 58
             $output = decode('cp1252', $bytes, Encode::FB_CROAK);
    
    58 59
     
    
    59
    -    } catch {
    
    60
    -        die 'In file ' . $item->name . $COLON . $SPACE . $@;
    
    60
    +    } catch ($e) {
    
    61
    +        if ($e =~ m{^cp1252 "\\x81" does not map to Unicode at .+}) {
    
    62
    +            try {
    
    63
    +                # sometimes, the file is utf8
    
    64
    +                $output = decode('utf8', $bytes, Encode::FB_CROAK);
    
    65
    +            } catch {
    
    66
    +                die $enc_warning . $@;
    
    67
    +            }
    
    68
    +        } else {
    
    69
    +            die $enc_warning . $@;
    
    70
    +        }
    
    61 71
         }
    
    62 72
     
    
    63 73
         my @lines = split(/\n/, $output);
    


  • Reply to: