boostorg / property_tree

Boost.org property_tree module
http://boost.org/libs/property_tree
55 stars 92 forks source link

Xml nullkey #89

Closed brchrisman closed 3 years ago

brchrisman commented 3 years ago

Added test and fixed string literal compatibility.

madmongo1 commented 3 years ago

Many thanks for the commit.

Is this seeking to change existing behaviour in legacy applications?

brchrisman commented 3 years ago

Many thanks for the commit.

Is this seeking to change existing behaviour in legacy applications?

No, it's fixing an apparently otherwise unused case where xml serialization of a property-tree with a null key will output null qnames/tagnames <> and </> which aren't well-formed XML. I ran across this while serializing a property-tree to xml, then patched it locally in my particular .hpp copy and figured I'd push a change upstream. It's nearly impossible that any applications are counting on property-tree-xml-serialization producing broken elements.

brchrisman commented 3 years ago

It looks like

./boost/property_tree/detail/xml_parser_write.hpp:113:17: error: no match for ternary ‘operator?:’ in ‘(& key)->std::basic_string<_CharT, _Traits, _Alloc>::empty<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >() ? nullkey : key’
./boost/property_tree/detail/xml_parser_write.hpp:171:17: error: no match for ternary ‘operator?:’ in ‘(& key)->std::basic_string<_CharT, _Traits, _Alloc>::empty<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >() ? nullkey : key’

looks like my char * nullkey needs to be the same type as 'key'... not sure how this compiles ok on my particular application... will get them to be of the same type.

madmongo1 commented 3 years ago

Yep, CI confirms the compilation failure.