// Default is all fine
$isValid = true;
+ // Split the (possible) EOP chunk
+ $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
+
+ // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
+ assert(count($chunkSplits) == 3);
+
// Validate final chunk
- if (substr($chunks[count($chunks) - 1], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
+ if (substr($chunkSplits[2], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
// Not fine
$isValid = false;
- } elseif (substr_count($chunks[count($chunks) - 1], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) {
+ } elseif (substr_count($chunkSplits[2], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) {
// CHUNK_HASH_SEPARATOR shall only be found once
$isValid = false;
}