diff --git a/docs/DETECTION.md b/docs/DETECTION.md new file mode 100644 index 0000000..88d17bf --- /dev/null +++ b/docs/DETECTION.md @@ -0,0 +1,40 @@ +# Detection of ODF Conditions + +## ODF Specification Errors + +### Package Errors + +| Ref | Detection | +|-----|-------------| +| PKG-1 | An OpenDocument package SHALL be a well formed Zip Archive.
This is effectively left to the zip library, if exceptions are rasied they are trapped and this error is raised. | +PKG-2 | All files contained in the Zip file shall be non compressed (STORED) or compressed using the "deflate" (DEFLATED) algorithm. Zip entry %s is compressed with an unknown algorithm.
The zip library is used to examine the compression algorithm used, if it's outside of the prescribed values, this error is raised. | +PKG-3 | An OpenDocument package SHALL contain a file "META-INF/manifest.xml".
Simply check whether such a zip entry exists. | +PKG-4 | An OpenDocument package SHOULD contain a file "mimetype".
Simply check whether such a zip entry exists. | +PKG-5 | An OpenDocument package SHALL only contain the "META-INF/manifest.xml" and files containg the term "signatures" in their name in the "META-INF" folder. File %s does not meet this criteria.
Each zip entry is examined. If a file is found below `META-INF/` that is not `manifest.xml` and whose name does not contain the term "signatures" this error is raised. | +PKG-7 | An OpenDocument package SHOULD contain a preview image Thumbnails/thumbnail.png.
Simply check whether such a zip entry exists. | + + +### Manifest Errors + +| Ref | Detection | +|-----|-------------| +| MAN-1 | The manifest SHALL contain an entry for every file in the package, zip entry %s has no corresponding manifest file entry.
The software creates two lists of package contents:These are then compared and this error is fired only if there is a Zip Entry that doesn't have a corresponding Manfiest Entry. | +| MAN-2 | An OpenDocument package manifest SHALL NOT contain a file entry for itself.
This simply detects the presence of a `META-INF/manifest.xml` `` element with a `manifest:full-path` attribute value `META-INF/manifest.xml`. | +| MAN-3 | An OpenDocument package manifest SHALL NOT contain a file entry the mimetype file.
This simply detects the presence of a `META-INF/manifest.xml` `` element with a `manifest:full-path` attribute value `mimetype`. | +| MAN-4 | The manifest SHALL contain an entry for every file in the package, manifest file entry %s has no corresponding zip entry.
The software creates two lists of package contents:These are then compared and this error is fired only if there is a Manifest Entry that doesn't have a corresponding Zip Entry. | +| MAN-5 | An OpenDocument package manifest SHALL contain a element whose manifest:full-path attribute has the value \"/\" if a mimetype file is present.
This rule checks that a `META-INF/manifest.xml` `` element with a `manifest:full-path` attribute value `/` exists. IF it doesn't AND a `mimetype` entry exists this error is fired, if a `mimetype` entry does not exist then the warning `MAN-7` is fired instead. | +| MAN-6 | The OpenDocument package manifest NEED NOT contain entries for file paths starting with META-INF/, %s.
This rule checks that a `META-INF/manifest.xml` `` element with a `manifest:full-path` attribute value starting with `META-INF/` exists. An information message that says this is unnecessary is raised. | +| MAN-7 | An OpenDocument package SHOULD contain a element whose manifest:full-path attribute has the value \"/\"".
This rule checks that a `META-INF/manifest.xml` `` element with a `manifest:full-path` attribute value `/` exists. IF it doesn't AND a `mimetype` entry also doesn't exist this warning is fired, if a `mimetype` entry does not exist then the error `MAN-5` is fired instead. | +| MAN-8 | For directories, the manifest file should contain a element only if a directory contains a document or a sub document.
Detection of sub-document rules WIP. | +| MAN-9 | A directory for administrative or convenience purposes, such as a directory that contains various unrelated image files, should not have an entry in the manifest file.
Detection of sub-document rules WIP. | + +### MIME Media Type Errors + +| Ref | Detection | +|-----|-------------| +| MIM-1 | The "mimetype" file SHALL be the first file of the zip file.
The zip archives entries are extracted in physical order and the name of the first entry is recorded. IF the package contains a `mimetype` file AND it is not the first entry this error is raised. | +| MIM-2 | The "mimetype" file SHALL NOT be compressed.
The software uses the zip library to examine the compression type used for the `mimetype` entry. If this is not `STORED` (which indicates no compression) then this error is raised. | +| MIM-3 | The "mimetype" file SHALL NOT use an 'extra field' in its header.
The software uses the zip library to retrieve the list of extra fields for the `mimetype` entry. If the retured array has a size > 0 then this error is raised. | +| MIM-4 | An OpenDocument package SHALL contain a mimetype file IF the manifest contains a element whose manifest:full-path attribute has the value "/".
IF the file doesn't contain a `mimetype` entry AND `META-INF/manifest.xml` DOES contain an entry with `manifest:full-path` "/" then this error is raised. If no such `` exists then the warning `PKG-4` is raised instead. | +| MIM-5 | An OpenDocument package mimetype file content SHALL be equal to the manifest:media-type attribute of the manifest element whose manifest:full-path attribute has the value \"/\".
IF the file doesn't contain a `mimetype` entry AND `META-INF/manifest.xml` DOES contain an entry with `manifest:full-path` "/" then the value of the `mimetype` file contents and the `manifest:media-type` attribute are compared. If they aren't equal then this error is raised. | +| MIM-6 | The content of the "mimetype" file SHALL be ASCII encoded.
Detection is impractical. |