From: konrad Date: Sat, 16 Jan 2010 22:40:38 +0000 (+0000) Subject: make toXml object serialization safer X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=1062b51a477e50ad55dcd159ca2f848db8a428e6;p=web%2Fkonrad%2Fpack.git make toXml object serialization safer git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@428 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/woc/phpout.cpp b/woc/phpout.cpp index 21766f9..a026a32 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -771,16 +771,16 @@ QString WocPHPServerOut::propertyToXml(const WocClass&cls,QString sl) } } //non lists: - QString code="\t$p=$this->get"+prop+"();\n\tif($p!==null)"; + QString code="\t$p=$this->get"+prop+"();\n"; //is it an attribute? if(cls.propertyIsAttribute(prop)) - return code+"\t$root->setAttribute(\""+prop+"\",$this->getstr_"+prop+"());\n"; + return code+"\tif($p!==null)$root->setAttribute(\""+prop+"\",$this->getstr_"+prop+"());\n"; //is it an element? if(cls.propertyIsElement(prop)) - return code+"\t$root->appendChild($xml->createElement(\""+prop+"\",xq($this->getstr_"+prop+"())));\n"; + return code+"\tif($p!==null)$root->appendChild($xml->createElement(\""+prop+"\",xq($this->getstr_"+prop+"())));\n"; //is it a class? if(cls.propertyIsObject(prop)) - return code+"$root->appendChild($p->toXml($xml,\""+prop+"\"));\n"; + return code+"\tif(is_a($p,\"WO"+cls.propertyPlainType(prop)+"\"))$root->appendChild($p->toXml($xml,\""+prop+"\"));\n"; //anything else? qDebug("Warning: end of WocPHPServerOut::propertyToXml - this code should not be reachable."); return "//internal generator error!\n";