Author: martinf
Date: Sat Jan 27 23:55:22 2007
New Revision: 25652
URL:
http://svn.reactos.org/svn/reactos?rev=25652&view=rev
Log:
update XMLStorage:
- optional CDATA embedding by set_content()
- fix for handling in XML parser
Modified:
trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp
trunk/reactos/base/shell/explorer/utility/xmlstorage.h
Modified: trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
==============================================================================
--- trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp (original)
+++ trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp Sat Jan 27 23:55:22 2007
@@ -279,12 +279,12 @@
/// 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 @@
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;
Modified: trunk/reactos/base/shell/explorer/utility/xmlstorage.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
==============================================================================
--- trunk/reactos/base/shell/explorer/utility/xmlstorage.h (original)
+++ trunk/reactos/base/shell/explorer/utility/xmlstorage.h Sat Jan 27 23:55:22 2007
@@ -409,7 +409,7 @@
#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 @@
return DecodeXMLString(ret.c_str());
}
- void set_content(const XS_String& s)
- {
- _content.assign(EncodeXMLString(s.c_str()));
+ void set_content(const XS_String& s, bool cdata=false)
+ {
+ _content.assign(EncodeXMLString(s.c_str(), cdata));
}
#ifdef XMLNODE_LOCATION
@@ -2391,10 +2391,10 @@
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