Skip to content

Kernel: PdfName writes a name over 127 bytes, a byte above 127 and a character above U+00FF without a check, and a font program's PostScript name reaches /BaseFont as it is #740

Backlog

Description

@Tim81

Why

ISO 19005-2, 6.1.13 limits a name to 127 bytes (veraPDF 1.30.4 rule 6.1.13-4), and 6.1.8 requires font names to be valid UTF-8 after # expansion (rule 6.1.8-1). PdfName.WriteTo encodes the value with Latin-1 (PdfName.cs:135): a character from U+0080 to U+00FF becomes one byte written as #XX, which is not UTF-8, and a character above U+00FF becomes ?.

Measured on origin/main bbf317b, Conformance = PdfA2b, with the in-tree DejaVu Sans whose name table was replaced by one holding a PostScript name (name ID 6):

PostScript name /BaseFont token veraPDF 2b
120 characters (127 bytes with the subset tag) 127 bytes compliant
121 characters (128 bytes with the tag) 128 bytes fails 6.1.13-4
Caf + U+00E9 BJLQVE+Caf#E9 fails 6.1.8-1
two CJK characters BJLQVE+?? no rule fires, but the name was changed silently

A caller-chosen resource name behaves the same way: RegisterImageXObject(page, image, new string('I', 128)) with DoXObject of the same name saves, and veraPDF 2b fails 6.1.13-4; at 127 characters it passes.

The font name comes from the font file. The OpenType name table (held copy) limits name ID 6 to 63 printable ASCII characters, with an exception for CFF fonts, so a TrueType-outline font that triggers this is not conforming. The library still writes a file that fails the claim it stamps, and it rewrites a CJK name to question marks without a word.

Sweep: new PdfName( with a non-literal argument is at PdfPage.cs:96-127 (resource names), PdfFontResource.cs:52 and TrueTypeFontEmbedder.cs:326-392 (font names), PdfStructureTree.cs:285,332 (structure types, which Save limits to the standard set, so they are short ASCII), PdfDocument.cs:1848 (signature SubFilter, which the options setter limits to two values), AcroFormBuilder.cs (export values, group G6) and DssBuilder.cs:419 (a VRI key). Only the font name and the resource names are open.

Proposal

Under a PDF/A level, refuse a font whose PostScript name has more than 120 characters or a character outside printable ASCII, and refuse a resource name over 127 bytes or outside ASCII, naming the clause. Without a claim, stop turning a character above U+00FF into ?: either refuse it or write its UTF-8 bytes (the name rules of ISO 32000-2, 7.3.5, were not re-read for this choice).

Acceptance

  • The skipped test ConformanceAuditG5Tests.Iso19005_2_6_1_8_And_6_1_13_NamesAreUtf8AndAtMost127BytesUnderAPdfAClaim runs and passes.
  • Iso19005_2_6_1_13_NamesOfExactly127BytesAreWrittenInFullAndPassVeraPdf still passes.

Activity

  1. added
    bug
    on Nov 27, 2026
  2. Tim81 commented on Nov 27, 2026

    @Tim81
    OwnerAuthor

    Also in this class, found in the review of #744: a name holding a null character, which ISO 32000-1 7.3.5 excludes, is written: RegisterImageXObject with the name "Im\0x" under PDF/A-2b writes /Im#00x. veraPDF passes it; qpdf --check reports "null character not allowed in name token". The fix should refuse it with the other name rules here.

  3. Tim81 commented on Nov 29, 2026

    @Tim81
    OwnerAuthor

    #740's sweep lists AcroFormBuilder.cs (export values, group G6) as a site it left to the forms audit. Measured on origin/main b2791ba with Conformance = PdfA2b, AddRadioButtonGroup with two buttons:

    export values written veraPDF 2b
    127 characters, B on-state name of 127 bytes 6.2.11.4.1-1 only (the font rule of #671)
    128 characters, B on-state name of 128 bytes 6.1.13-4 and 6.2.11.4.1-1
    U+6F22 and U+5B57, selectedExportValue U+5B57 both on-state names are /?, and the parent's V is /? 6.2.11.4.1-1 only

    The third row is the same substitution #740 measured for a font name: PdfName.WriteTo writes a character above U+00FF as ?. Here it makes two different buttons the same name, so the parent's V cannot name one of them (ISO 32000-1, 12.7.4.2.4; ISO 32000-2, 7.3.5: names that differ denote different objects). A value from U+0080 to U+00FF is written as #XX, one Latin-1 byte (caf#E9#20x for café x).

    Suggest adding the export value to #740's proposal and acceptance: refuse an export value over 127 bytes under a PDF/A claim, and refuse (or write as UTF-8) a character above U+00FF.

    Tests: ConformanceAuditG6Tests.Iso19005_2_6_1_13_ARadioExportValueIsANameOfAtMost127BytesThatNamesOneButton (skipped) and the pin Iso19005_2_6_1_13_PinsTodayARadioExportValueOf128BytesAndTwoValuesAbove255CollideAsQuestionMarks.

  4. Tim81 commented on Nov 29, 2026

    @Tim81
    OwnerAuthor

    The ISO audit (docs/conformance-v2.4.md) has skipped tests that wait on this issue; the fix removes their skip and makes them pass.

    • Iso32000_1_7_3_5_ANameHoldsNoNullCharacter (group G5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions