User:Jorge.villalobos/AddonPackaging/Parsing

From MozillaWiki
Jump to: navigation, search

Parsing the Manifest File

The manifest file is laid out as HTML in order to facilitate the work for developers. However, there's no need to use an HTML parser to process the file, since it will only be used to extract data out of it.

The file will be required to be valid XML, so it should be parsed using the generic XML parser for performance.

Integrity checks

The file needs to have an <html> root node with a <body> child node, and all manifest data should be inside the body. Nodes like <head> can exist outside of the body, but they will be ignored.

All required properties must be declared and have correct values.

<script> nodes are strictly forbidden, and installation should be cancelled if one is found.

Getting the data

The id and class attributes can be used to obtain all manifest data. Tag names are not required to match the spec, as long as the node structure is respected.

For example, the spec requires the following to declare additional developers:

<ol id="developers">
  <li>John Doe</li>
  <li>Jane Doe</li>
</ol>

However, the following format should also be accepted:

<div id="developers" class="red">
  <span>John Doe</span>
  <span>Jane Doe</span>
</div>

Unnecessary nodes and attributes are ignored.