Skip to content

[Dependency] smalot/pdfparser: Font::getDetails() throws TypeError for PDFs with indirect /Encoding objects (upstream fix available in #822/#823) #7706

Description

@kernie

Bug Report

Note: This is not a bug in LibreSign itself, but a heads-up about a bug in a vendored dependency that affects LibreSign users.

Summary

When uploading certain PDF files (e.g. PDFs with Type1 fonts where is an indirect object reference), LibreSign throws a fatal error:

This originates in the vendored library at:

Root Cause

The PDF spec (Table 5.11) allows a font's entry to be either a name or an indirect reference to an encoding dictionary (). When it is an indirect reference, tried to cast the to string via , which throws a in PHP 8+ because has no .

The affected PDF is not corrupt — it is valid per the PDF specification.

Upstream Fix

This has been reported and fixed upstream in :

The fix adds a type-safe branch in that handles encoding dictionaries by reading the header entry instead of casting to string.

Request

Please update the vendored in to a version that includes the upstream fix (once merged), so that LibreSign users are no longer affected by this error.

Environment

  • Nextcloud version: 33.0.5.1
  • LibreSign vendored pdfparser commit:
  • PHP version: 8.x
  • Triggered by: Uploading a EncodingAsIndirectPDFObject.pdf PDF with Type1 fonts using indirect references

Nextcloud Log

Workaround

Until the vendored library is updated, the fix can be applied manually to:
3rdparty/composer/smalot/pdfparser/src/Smalot/PdfParser/Font.php

Replace the Encoding line in getDetails() with:

\$encoding = \$this->has('Encoding') ? \$this->get('Encoding') : null;
if (\$encoding instanceof PDFObject) {
    \$baseEncoding = \$encoding->getHeader()->get('BaseEncoding');
    \$details['Encoding'] = (\$baseEncoding instanceof Element && (string) \$baseEncoding !== '')
        ? (string) \$baseEncoding
        : 'Ansi';
} elseif (\$encoding instanceof Element) {
    \$details['Encoding'] = (string) \$encoding;
} else {
    \$details['Encoding'] = 'Ansi';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    0. Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions