Fixed a bug where text of XML element cannot be empty. (#3643)
This commit is contained in:
parent
0e68b12f44
commit
fc2f7c53b3
@ -8,6 +8,8 @@
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fixed a bug where text of XML element cannot be empty.
|
||||
|
||||
### Other Changes
|
||||
|
||||
## 12.2.3 (2022-04-06)
|
||||
|
||||
@ -19,17 +19,20 @@ namespace Azure { namespace Storage { namespace _internal {
|
||||
|
||||
struct XmlNode final
|
||||
{
|
||||
explicit XmlNode(
|
||||
XmlNodeType type,
|
||||
std::string name = std::string(),
|
||||
std::string value = std::string())
|
||||
: Type(type), Name(std::move(name)), Value(std::move(value))
|
||||
explicit XmlNode(XmlNodeType type, std::string name = std::string())
|
||||
: Type(type), Name(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
explicit XmlNode(XmlNodeType type, std::string name, std::string value)
|
||||
: Type(type), Name(std::move(name)), Value(std::move(value)), HasValue(true)
|
||||
{
|
||||
}
|
||||
|
||||
XmlNodeType Type;
|
||||
std::string Name;
|
||||
std::string Value;
|
||||
bool HasValue = false;
|
||||
};
|
||||
|
||||
class XmlReader final {
|
||||
|
||||
@ -203,7 +203,7 @@ namespace Azure { namespace Storage { namespace _internal {
|
||||
}
|
||||
case WS_XML_NODE_TYPE_END_ELEMENT:
|
||||
moveToNext();
|
||||
return XmlNode{XmlNodeType::EndTag, std::string()};
|
||||
return XmlNode{XmlNodeType::EndTag};
|
||||
case WS_XML_NODE_TYPE_EOF:
|
||||
return XmlNode{XmlNodeType::End};
|
||||
case WS_XML_NODE_TYPE_CDATA:
|
||||
@ -288,7 +288,7 @@ namespace Azure { namespace Storage { namespace _internal {
|
||||
auto context = static_cast<XmlWriterContext*>(m_context);
|
||||
if (node.Type == XmlNodeType::StartTag)
|
||||
{
|
||||
if (!node.Value.empty())
|
||||
if (node.HasValue)
|
||||
{
|
||||
Write(XmlNode{XmlNodeType::StartTag, std::move(node.Name)});
|
||||
Write(XmlNode{XmlNodeType::Text, std::string(), std::move(node.Value)});
|
||||
@ -576,7 +576,7 @@ namespace Azure { namespace Storage { namespace _internal {
|
||||
xmlTextWriterPtr writer = context->writer;
|
||||
if (node.Type == XmlNodeType::StartTag)
|
||||
{
|
||||
if (node.Value.empty())
|
||||
if (!node.HasValue)
|
||||
{
|
||||
xmlTextWriterStartElement(writer, BadCast(node.Name.data()));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user