Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/azure-storage-common/src/xml_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)});
Expand Down Expand Up @@ -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()));
}
Expand Down