From 0c6471da931839b4e934d87df27ef208c74355c3 Mon Sep 17 00:00:00 2001 From: neoraider Date: Fri, 11 Apr 2008 10:28:03 +0000 Subject: zoomedit: * Added DTD validation of level files. --- src/Instance.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Instance.cpp b/src/Instance.cpp index eb4d9dd..fe4b761 100644 --- a/src/Instance.cpp +++ b/src/Instance.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "Instance.h" #include "Gui/Window.h" #include "Data/Level.h" @@ -103,11 +104,15 @@ void Instance::createLevel() { root->add_child("rooms"); root->add_child("gates"); root->add_child("textures"); + + level = new Data::Level(root); } bool Instance::loadLevel(const Glib::ustring &file) { - if(level) + if(level) { delete level; + level = NULL; + } if(levelXml) delete levelXml; @@ -115,8 +120,13 @@ bool Instance::loadLevel(const Glib::ustring &file) { levelXml = new xmlpp::DomParser(file); xmlpp::Document *doc = levelXml->get_document(); - if(doc && doc->get_root_node()) - level = new Data::Level(doc->get_root_node()); + if(!doc || !doc->get_root_node()) + return false; + + if(!xmlpp::DtdValidator("level.dtd").validate(doc)) + return false; + + level = new Data::Level(doc->get_root_node()); return (level != NULL); } -- cgit v1.2.3