diff --git a/src/ssn/verify/verifyPatchmanifest.ts b/src/ssn/verify/verifyPatchmanifest.ts index 56485a8..753dc9f 100644 --- a/src/ssn/verify/verifyPatchmanifest.ts +++ b/src/ssn/verify/verifyPatchmanifest.ts @@ -28,8 +28,20 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product // const Dependencies = PatchManifest.elements[0]; - if (Dependencies.type !== 'element' || Dependencies.name !== 'Dependencies' || Dependencies.attributes !== undefined || Dependencies.elements !== undefined) { - throw new Error('Expected Dependencies element with no child elements and no attributes.'); + if (Dependencies.type !== 'element' || Dependencies.name !== 'Dependencies' || Dependencies.attributes !== undefined) { + throw new Error('Expected Dependencies element with no attributes.'); + } + const hasDependencies = product.startsWith('retailclient_'); + if (Dependencies.elements !== undefined && !hasDependencies) { + throw new Error('Expected Dependencies element with no child elements.'); + } + if (hasDependencies) { + for (const Dependency of (Dependencies.elements as xmlJs.Element[])) { + if (Dependency.type !== 'element' || Dependency.name !== 'Dependency' || Dependency.attributes !== undefined) { + throw new Error('Expected Dependency element with no attributes.'); + } + //TODO: check text nodes + } } //assets_swtor_de_de @@ -88,8 +100,7 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product if (Releases.type !== 'element' || Releases.name !== 'Releases' || Releases.attributes !== undefined || Releases.elements === undefined) { throw new Error('Expected Releases element.'); } - for (let i = 0, il = Releases.elements.length; i < il; i += 1) { - const Release = Releases.elements[i]; + for (const Release of Releases.elements) { // if (Release.type !== 'element' || Release.name !== 'Release' || Release.attributes !== undefined || Release.elements === undefined || Release.elements.length !== 3) { throw new Error('Expected Release element.'); @@ -116,8 +127,7 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product if (ReleaseUpdatePaths.type !== 'element' || ReleaseUpdatePaths.name !== 'ReleaseUpdatePaths' || ReleaseUpdatePaths.attributes !== undefined || ReleaseUpdatePaths.elements === undefined) { throw new Error('Expected ReleaseUpdatePaths element.'); } - for (let i = 0, il = ReleaseUpdatePaths.elements.length; i < il; i += 1) { - const ReleaseUpdatePath = ReleaseUpdatePaths.elements[i]; + for (const ReleaseUpdatePath of ReleaseUpdatePaths.elements) { // if (ReleaseUpdatePath.type !== 'element' || ReleaseUpdatePath.name !== 'ReleaseUpdatePath' || ReleaseUpdatePath.attributes !== undefined || ReleaseUpdatePath.elements === undefined || ReleaseUpdatePath.elements.length !== 3) { throw new Error('Expected ReleaseUpdatePath element.'); @@ -151,10 +161,8 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product throw new Error(`Expected ExtraData element with children in patch ${fromNum}to${toNum}.`); } if (!isPatchWithoutExtraData) { - const ExtraDataItems = ExtraData.elements as xmlJs.Element[]; - for (let j = 0, jl = ExtraDataItems.length; j < jl; j += 1) { + for (const ExtraDataItem of (ExtraData.elements as xmlJs.Element[])) { // - const ExtraDataItem = ExtraDataItems[j]; if (ExtraDataItem.type !== 'element' || ExtraDataItem.name !== 'ExtraDataItem' || ExtraDataItem.attributes !== undefined || ExtraDataItem.elements === undefined || ExtraDataItem.elements.length !== 2) { throw new Error('Expected ExtraDataItem element.'); }