Merge pull request #23503 from maxwxyz/issue-22123

Fix STEP import with bad string behavior
This commit is contained in:
Chris Hennes
2025-08-31 23:23:25 -05:00
committed by GitHub
6 changed files with 76 additions and 0 deletions

View File

@@ -1509,6 +1509,14 @@ void PropertyString::setPyObject(PyObject* value)
void PropertyString::Save(Base::Writer& writer) const
{
auto verifyXMLString = [this](std::string& input) {
const std::string output = this->validateXMLString(input);
if (output != input) {
Base::Console().warning("XML output: Validate invalid string:\n'%s'\n'%s'\n",
input, output);
}
return output;
};
std::string val;
auto obj = freecad_cast<DocumentObject*>(getContainer());
writer.Stream() << writer.ind() << "<String ";
@@ -1520,11 +1528,13 @@ void PropertyString::Save(Base::Writer& writer) const
else if (_cValue == obj->getNameInDocument()) {
writer.Stream() << "restore=\"0\" ";
val = encodeAttribute(obj->getExportName());
val = verifyXMLString(val);
exported = true;
}
}
if (!exported) {
val = encodeAttribute(_cValue);
val = verifyXMLString(val);
}
writer.Stream() << "value=\"" << val << "\"/>" << std::endl;
}