make toXml object serialization safer
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 16 Jan 2010 22:40:38 +0000 (22:40 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 16 Jan 2010 22:40:38 +0000 (22:40 +0000)
git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@428 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

woc/phpout.cpp

index 21766f9..a026a32 100644 (file)
@@ -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";