mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 01:13:38 +00:00
update XMLStorage:
- optional CDATA embedding by set_content() - fix for handling in XML parser svn path=/trunk/; revision=25652
This commit is contained in:
parent
281da1dd05
commit
81557f635c
|
@ -279,12 +279,12 @@ XMLNode* XMLNode::create_relative(const char* path)
|
|||
|
||||
|
||||
/// encode XML string literals
|
||||
std::string EncodeXMLString(const XS_String& str)
|
||||
std::string EncodeXMLString(const XS_String& str, bool cdata)
|
||||
{
|
||||
LPCXSSTR s = str.c_str();
|
||||
size_t l = XS_len(s);
|
||||
|
||||
if (l <= BUFFER_LEN) {
|
||||
if (!cdata && l<=BUFFER_LEN) {
|
||||
LPXSSTR buffer = (LPXSSTR)alloca(6*sizeof(XS_CHAR)*XS_len(s)); // worst case """ / "'"
|
||||
LPXSSTR o = buffer;
|
||||
|
||||
|
@ -410,10 +410,10 @@ XS_String DecodeXMLString(const XS_String& str)
|
|||
p += 5;
|
||||
} else
|
||||
*o++ = *p;
|
||||
} else if (*p=='<' && !XS_nicmp(p+1,XS_TEXT("!CDATA["),7)) {
|
||||
p += 9;
|
||||
LPCXSSTR e = XS_strstr(p, XS_TEXT("]]>"));
|
||||
} else if (*p=='<' && !XS_nicmp(p+1,XS_TEXT("![CDATA["),8)) {
|
||||
LPCXSSTR e = XS_strstr(p+9, XS_TEXT("]]>"));
|
||||
if (e) {
|
||||
p += 9;
|
||||
size_t l = e - p;
|
||||
memcpy(o, p, l);
|
||||
o += l;
|
||||
|
|
|
@ -409,7 +409,7 @@ inline std::string get_utf8(const XS_String& s)
|
|||
|
||||
#endif // XS_STRING_UTF8
|
||||
|
||||
extern std::string EncodeXMLString(const XS_String& str);
|
||||
extern std::string EncodeXMLString(const XS_String& str, bool cdata=false);
|
||||
extern XS_String DecodeXMLString(const XS_String& str);
|
||||
|
||||
|
||||
|
@ -940,9 +940,9 @@ struct XMLNode : public XS_String
|
|||
return DecodeXMLString(ret.c_str());
|
||||
}
|
||||
|
||||
void set_content(const XS_String& s)
|
||||
void set_content(const XS_String& s, bool cdata=false)
|
||||
{
|
||||
_content.assign(EncodeXMLString(s.c_str()));
|
||||
_content.assign(EncodeXMLString(s.c_str(), cdata));
|
||||
}
|
||||
|
||||
#ifdef XMLNODE_LOCATION
|
||||
|
@ -2391,10 +2391,10 @@ struct XMLWriter
|
|||
return _stack.top()._attributes[attr_name];
|
||||
}
|
||||
|
||||
void set_content(const XS_String& s)
|
||||
void set_content(const XS_String& s, bool cdata=false)
|
||||
{
|
||||
if (!_stack.empty())
|
||||
_stack.top()._content = EncodeXMLString(s.c_str());
|
||||
_stack.top()._content = EncodeXMLString(s.c_str(), cdata);
|
||||
}
|
||||
|
||||
// public for access in StackEntry
|
||||
|
|
Loading…
Reference in a new issue