4 ms·
It's worth getting the escaping right in a library like this. For example, at https://github.com/tinfoilboy/CTML/blob/master/include/ctml.hpp#L215 https://githu
by tlb 8y ago
It's worth getting the escaping right in a library like this. For example, at https://github.com/tinfoilboy/CTML/blob/master/include/ctml.hpp#L215 https://github.com/tinfoilboy/CTML/blob/master/include/ctml....
for (const auto& attr : m_attributes)
output << " " << attr.first + "=\"" << attr.second + "\"";
it'll generate incorrect HTML if an attribute value has a " character. Although early versions of HTML were kind of vague on how escaping was supposed to work, the HTML5 standard explains it in detail.
- tinfoilboy 8y agoI'll add escaping attributes to the library according to the spec. Thank you for the heads up!
- sail0rm00n 8y agohttps://en.cppreference.com/w/cpp/io/manip/quoted https://en.cppreference.com/w/cpp/io/manip/quoted std::quoted might be useful
- im3w1l 8y agoPlease look it over once, twice and thrice. Getting escaping correct is the main reason to use a library like this over manual construction with a heap of string concatenations.