open-eid / digidoc4j

DigiDoc for Java. Javadoc:
http://open-eid.github.io/digidoc4j
GNU Lesser General Public License v2.1
72 stars 40 forks source link

DigiDoc4J tries to parse any binary file that added to container as XML #108

Open cbxp opened 2 years ago

cbxp commented 2 years ago

Resulting in the following logs in system error every time: [Fatal Error] :1:1: Content is not allowed in prolog.

This message is written by Xerces (included in the JDK), as a result of the following code in DomUtils:

    public static boolean isDOM(final byte[] bytes) {
        try {
            final Document dom = buildDOM(bytes);
            return dom != null;
        } catch (DSSException e) {
            // NOT DOM
            return false;
        }
    }

The question is, why do you try to parse application/pdf binary content as XML? If you still do, then please ensure no misleading errors are printed that people need to investigate...