diff -r 80e129ec3408 -r fd669e73d39a src/lib/UnescapingINIHandler.h --- a/src/lib/UnescapingINIHandler.h Wed Nov 25 21:50:26 2020 +0100 +++ b/src/lib/UnescapingINIHandler.h Thu Nov 26 11:42:26 2020 +0100 @@ -31,6 +31,7 @@ class UnescapingINIContentHandler : public INIContentHandler { private: INIContentHandler& output; + bool unescapeComments; protected: const char ESC = '\\'; @@ -53,7 +54,7 @@ * in the last phase, all remaining sequences (including \\) must be recognized and unescaped * (otherwise the input is considered invalid and an exception is thrown) */ - UnescapingINIContentHandler(INIContentHandler& output, bool lastEscaphingPhase) : output(output), lastEscaphingPhase(lastEscaphingPhase) { + UnescapingINIContentHandler(INIContentHandler& output, bool lastEscaphingPhase, bool unescapeComments = false) : output(output), lastEscaphingPhase(lastEscaphingPhase), unescapeComments(unescapeComments) { } void startDocument() override { @@ -67,6 +68,7 @@ void startSection(const SectionStartEvent& event) override { SectionStartEvent e = event; e.name = unescape(e.name); + if (unescapeComments) e.comment = unescape(e.comment); output.startSection(e); } @@ -80,11 +82,18 @@ e.fullKey = unescape(e.fullKey); e.subKey = unescape(e.subKey); e.value = unescape(e.value); + if (unescapeComments) e.comment = unescape(e.comment); output.entry(e); } void comment(const CommentEvent& event) override { - output.comment(event); + if (unescapeComments) { + CommentEvent e = event; + e.comment = unescape(e.comment); + output.comment(e); + } else { + output.comment(event); + } } void whitespace(const WhitespaceEvent& event) override {