Improve mindmap format validation.

main
Paulo Gustavo Veiga 2022-03-26 21:06:51 -03:00
parent c5c47892cb
commit 20b2e8f1e8
1 changed files with 7 additions and 1 deletions

View File

@ -36,10 +36,16 @@ abstract public class MindmapUtils {
throw InvalidMindmapException.invalidFormat(xmlDoc);
}
// Validate that the number of nodes is not bigger 500 nodes.
int numberOfTopics = xmlDoc.split("<topic").length;
// Any valid map must contain at least a central topic ...
if (numberOfTopics == 0) {
throw InvalidMindmapException.invalidFormat(xmlDoc);
}
// Validate that the number of nodes is not bigger 5000 nodes.
if (numberOfTopics > MAX_SUPPORTED_NODES) {
throw InvalidMindmapException.tooBigMindnap(numberOfTopics);
}
}
}