[recipes] Escape some characters when extracting strings



commit 495293649e39ffed1edc89d1e8dcf8a331193f8d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 1 21:28:39 2017 -0500

    Escape some characters when extracting strings
    
    This is just the minimum necessary to avoid breakage with the
    current strings.

 tools/recipe-extract.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/tools/recipe-extract.c b/tools/recipe-extract.c
index 41ac56d..9389a2a 100644
--- a/tools/recipe-extract.c
+++ b/tools/recipe-extract.c
@@ -28,10 +28,19 @@
 static void
 emit_string (const char *s)
 {
+        const char *p;
+        g_autoptr(GString) s2 = NULL;
         g_auto(GStrv) strv = NULL;
         int i;
 
-        strv = g_strsplit (s, "\n", -1);
+        s2 = g_string_new ("");
+        for (p = s; *p; p++) {
+                if (*p == '"' || *p == '\\')
+                        g_string_append_c (s2, '\\');
+                g_string_append_c (s2, *p);
+        }
+
+        strv = g_strsplit (s2->str, "\n", -1);
 
         for (i = 0; strv[i]; i++) {
                 if (strv[i][0] != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]