]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- fixed Pipe::escape 700/head
authorArvin Schnell <aschnell@suse.de>
Tue, 22 Mar 2022 09:43:13 +0000 (10:43 +0100)
committerArvin Schnell <aschnell@suse.de>
Tue, 22 Mar 2022 09:43:13 +0000 (10:43 +0100)
dbus/DBusMessage.cc
dbus/DBusPipe.cc
testsuite/dbus-escape.cc

index 2daf7fb5c86f6cd9f7c585d8b1a74c4210142ed9..0d1d885960440e23565d08f2d5fe4d787fc8fa03 100644 (file)
@@ -377,21 +377,21 @@ namespace DBus
     {
        string out;
 
-       for (string::const_iterator it = in.begin(); it != in.end(); ++it)
+       for (const char c : in)
        {
-           if (*it == '\\')
+           if (c == '\\')
            {
                out += "\\\\";
            }
-           else if ((unsigned char)(*it) > 127)
+           else if ((unsigned char)(c) > 127)
            {
                char s[5];
-               snprintf(s, 5, "\\x%02x", (unsigned char)(*it));
+               snprintf(s, 5, "\\x%02x", (unsigned char)(c));
                out += string(s);
            }
            else
            {
-               out += *it;
+               out += c;
            }
        }
 
index df26324e1e3fda744766547fd03f0c5c73452d0e..b332062ec73001de6389df367a6bbb691025ec3f 100644 (file)
@@ -89,10 +89,10 @@ namespace DBus
            {
                out += "\\\\";
            }
-           else if (c <= ' ')
+           else if ((unsigned char)(c) <= ' ')
            {
                char s[5];
-               snprintf(s, 5, "\\x%02x", c);
+               snprintf(s, 5, "\\x%02x", (unsigned char)(c));
                out += string(s);
            }
            else
index 038a7b2cb9c89bcb5d4351e4d89fe7d4165261c3..cbb1f037df402bd1dbaa06242b4b3690c9f9aee0 100644 (file)
@@ -41,10 +41,14 @@ BOOST_AUTO_TEST_CASE(hihi_unescape)
 BOOST_AUTO_TEST_CASE(pipe_escape)
 {
     BOOST_CHECK_EQUAL(Pipe::escape("hello world\n"), "hello\\x20world\\x0a");
+
+    BOOST_CHECK_EQUAL(Pipe::escape("ä"), "ä");
 }
 
 
 BOOST_AUTO_TEST_CASE(pipe_unescape)
 {
     BOOST_CHECK_EQUAL(Pipe::unescape("hello\\x20world\\x0a"), "hello world\n");
+
+    BOOST_CHECK_EQUAL(Pipe::unescape("ä"), "ä");
 }