Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.verapdf.metadata.fixer.utils.model.ProcessedObjects;
import org.verapdf.metadata.fixer.utils.model.RuleDescription;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.flavours.PDFFlavours;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -109,7 +110,7 @@ public String getProcessedObjectsPathProperty(PDFAFlavour flavour) {
if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_1) {
return XML_PROCESSED_OBJECTS_PATH_PROPERTY_PDFA_1;
}
if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_4) {
if (PDFFlavours.isPDFA4RelatedFlavour(flavour)) {
return XML_PROCESSED_OBJECTS_PATH_PROPERTY_PDFA_4;
}
if (flavour.getPart() == PDFAFlavour.Specification.ISO_14289_1) {
Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public enum PDFAFlavour {
/** 3u PDF Version 3 Level U */
PDFA_3_U(Specification.ISO_19005_3, Level.U),
/** 4 PDF Version 4 */
PDFA_4_2020(Specification.ISO_19005_4_2020, Level.NO_LEVEL),
/** 4 PDF Version 4 Level F */
PDFA_4_F_2020(Specification.ISO_19005_4_2020, Level.F),
/** 4 PDF Version 4 Level E */
PDFA_4_E_2020(Specification.ISO_19005_4_2020, Level.E),
/** 4 PDF Version 4 */
PDFA_4(Specification.ISO_19005_4, Level.NO_LEVEL),
Comment on lines +89 to 95
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

ID collision between 2020 and default PDF/A-4 flavours breaks lookup.

Line 89-Line 95 add new flavours that currently generate the same IDs (4, 4f, 4e) as Line 95-Line 99 variants. This causes map overwrites in ID-based lookup paths (FLAVOUR_LOOKUP, and downstream profile ID maps), so 2020 flavours are not uniquely addressable by ID.

🔧 Proposed fix: assign explicit unique IDs to 2020 variants
-    PDFA_4_2020(Specification.ISO_19005_4_2020, Level.NO_LEVEL),
+    PDFA_4_2020("4-2020", Specification.ISO_19005_4_2020, Level.NO_LEVEL),
...
-    PDFA_4_F_2020(Specification.ISO_19005_4_2020, Level.F),
+    PDFA_4_F_2020("4f-2020", Specification.ISO_19005_4_2020, Level.F),
...
-    PDFA_4_E_2020(Specification.ISO_19005_4_2020, Level.E),
+    PDFA_4_E_2020("4e-2020", Specification.ISO_19005_4_2020, Level.E),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java` around lines
89 - 95, The PDFAFlavour enum entries PDFA_4_2020, PDFA_4_F_2020, PDFA_4_E_2020
currently share the same implicit IDs as PDFA_4 / PDFA_4_F / PDFA_4_E causing
FLAVOUR_LOOKUP map collisions; fix by giving the 2020 variants explicit unique
IDs (for example "4_2020", "4f_2020", "4e_2020") when constructing those enum
constants so their getId() values differ and the FLAVOUR_LOOKUP/profile ID maps
won’t overwrite; update the enum constant declarations (PDFA_4_2020,
PDFA_4_F_2020, PDFA_4_E_2020) to call the constructor that accepts an explicit
id string (or add such a constructor and set the id field) and leave existing
PDFA_4 variants unchanged.

/** 4 PDF Version 4 Level F */
PDFA_4_F(Specification.ISO_19005_4, Level.F),
Expand Down Expand Up @@ -208,8 +214,12 @@ public enum Specification {
PDFAFlavours.ISO_19005_3_PART, PDFAFlavours.NONE_SUBPART, PDFAFlavours.ISO_19005_3_YEAR,
PDFAFlavours.ISO_19005_3_DESCRIPTION),
/** PDF/A Version 4 */
ISO_19005_4_2020(IsoStandardSeries.ISO_19005, PDFSpecification.ISO_32000_2_0, SpecificationFamily.PDF_A,
PDFAFlavours.ISO_19005_4_PART, PDFAFlavours.NONE_SUBPART, PDFAFlavours.ISO_19005_4_2020_YEAR,
PDFAFlavours.ISO_19005_4_DESCRIPTION),
/** PDF/A Version 4 */
ISO_19005_4(IsoStandardSeries.ISO_19005, PDFSpecification.ISO_32000_2_0, SpecificationFamily.PDF_A,
PDFAFlavours.ISO_19005_4_PART, PDFAFlavours.NONE_SUBPART, PDFAFlavours.ISO_19005_4_YEAR,
PDFAFlavours.ISO_19005_4_PART, PDFAFlavours.NONE_SUBPART, PDFAFlavours.ISO_19005_4_2026_YEAR,
PDFAFlavours.ISO_19005_4_DESCRIPTION),
ISO_32005(IsoStandardSeries.ISO_32005, PDFSpecification.ISO_32000_2_0, SpecificationFamily.TAGGED_PDF,
PDFAFlavours.NONE_PART, PDFAFlavours.NONE_SUBPART, PDFAFlavours.ISO_32005_YEAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public final class PDFAFlavours {
static final String ISO_19005_1_YEAR = "2005"; //$NON-NLS-1$
static final String ISO_19005_2_YEAR = "2011"; //$NON-NLS-1$
static final String ISO_19005_3_YEAR = "2012"; //$NON-NLS-1$
static final String ISO_19005_4_YEAR = "2020"; //$NON-NLS-1$
public static final String ISO_19005_4_2020_YEAR = "2020"; //$NON-NLS-1$
static final String ISO_19005_4_2026_YEAR = "2026"; //$NON-NLS-1$
static final String ISO_32005_YEAR = "2023"; //$NON-NLS-1$
static final String WCAG_2_1_YEAR = "2018"; //$NON-NLS-1$
static final String WCAG_2_2_YEAR = "2023"; //$NON-NLS-1$
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/org/verapdf/pdfa/flavours/PDFFlavours.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ public static boolean isWTPDFFlavour(PDFAFlavour flavour) {
return isFlavourFamily(flavour, PDFAFlavour.SpecificationFamily.WTPDF);
}

public static boolean isPDFA4RelatedFlavour(List<PDFAFlavour> flavours) {
for (PDFAFlavour flavour : flavours) {
if (isPDFA4RelatedFlavour(flavour)) {
return true;
}
}
return false;
}

public static boolean isPDFA4RelatedFlavour(PDFAFlavour flavour) {
return isFlavourPart(flavour, PDFAFlavour.Specification.ISO_19005_4) ||
isFlavourPart(flavour, PDFAFlavour.Specification.ISO_19005_4_2020);
}

public static boolean isFlavour(List<PDFAFlavour> flavours, PDFAFlavour checkedFlavour) {
for (PDFAFlavour flavour : flavours) {
if (isFlavour(flavour, checkedFlavour)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.verapdf.core.Directory;
import org.verapdf.core.MapBackedDirectory;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.flavours.PDFAFlavours;
import org.verapdf.pdfa.flavours.PDFFlavours;

/**
Expand Down Expand Up @@ -183,6 +184,9 @@ private static String getProfilePath(PDFAFlavour flavour) {
} else {
profilePath.append(flavour.getLevel().getCode().toUpperCase()); //$NON-NLS-1$
}
if (PDFFlavours.isFlavourPart(flavour, PDFAFlavour.Specification.ISO_19005_4_2020)) {
profilePath.append("-").append(PDFAFlavours.ISO_19005_4_2020_YEAR);
}
if (PDFFlavours.isFlavour(flavour, PDFAFlavour.PDFUA_2)) {
profilePath.append("-").append("ISO32005");
}
Expand Down
Loading