Blame SOURCES/0006-config-ignore-trailing-blank-lines-of-multiline-value-RhBug1722493.patch

885e9e
From 9e670738044166cdd0bf566325bf610bfb802821 Mon Sep 17 00:00:00 2001
885e9e
From: Jaroslav Rohel <jrohel@redhat.com>
885e9e
Date: Mon, 24 Jun 2019 16:34:47 +0200
885e9e
Subject: [PATCH] [config] ignore trailing blank lines of multiline value (RhBug:1722493)
885e9e
885e9e
Parser supports multiline values. Example:
885e9e
key = value first line
885e9e
  value second line
885e9e
885e9e
If a line starts with whitespaces and it is not a section name,
885e9e
it is treated as continuation of previous key=value line.
885e9e
885e9e
This commit ignores trailing blank lines. So newline characters
885e9e
are trimmed out from the end of line.
885e9e
---
885e9e
 libdnf/utils/iniparser/iniparser.cpp | 3 +++
885e9e
 1 file changed, 3 insertions(+)
885e9e
885e9e
diff --git a/libdnf/utils/iniparser/iniparser.cpp b/libdnf/utils/iniparser/iniparser.cpp
885e9e
index c77c5ca..14fef74 100644
885e9e
--- a/libdnf/utils/iniparser/iniparser.cpp
885e9e
+++ b/libdnf/utils/iniparser/iniparser.cpp
885e9e
@@ -81,6 +81,9 @@ IniParser::IniParser(std::unique_ptr<std::istream> && inputStream)
885e9e
 }
885e9e
 
885e9e
 void IniParser::trimValue() noexcept {
885e9e
+    auto end = value.find_last_not_of(DELIMITER);
885e9e
+    if (end != value.npos)
885e9e
+        value.resize(end + 1);
885e9e
     if (value.length() > 1 &&
885e9e
         value.front() == value.back() &&
885e9e
         (value.front() == '\"' || value.front() == '\'')) {
885e9e
--
885e9e
libgit2 0.28.2
885e9e