IATI / IATI-Validator-Actual

GNU Affero General Public License v3.0
1 stars 0 forks source link

Fix fatal error when namespace isn't declared in XML #23

Closed nosvalds closed 3 years ago

nosvalds commented 3 years ago

Previously

If a file used a custom namespace without declaring it, the file would cause a fatal error in the Saxon parser

[xslt] Caught an error during transformation: net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; systemId: file:/work/space/src/e431887d-d7b1-4539-b0d3-97db96084690.xml; lineNumber: 3; columnNumber: 181; The prefix "iati-extra" for attribute "iati-extra:version" associated with an element type "iati-activity" is not bound.

This would cause the validator to stall processing uploaded files as it would continuously re-try this file.

Now

A file using a custom namespace without a declaration will be treated as malformed XML and will return a response with a 'not-an-xml-file' error.

Testing

A test has been added in tests/non-iati-files.xspec which is now passing.

To run tests: Build image - docker build -t my_validator:latest . Run tests - docker run --rm my_validator test