Package: libconfuse0
Version: 2.5-1
Severity: normal
Tags: upstream

Hi Aurélien,

if you set a string parameter with a string containing a double quote (")
with a simple cfg_setstr and then you print the resulting configuration
file with cfg_print, the generated configuration is invalid:
parameter = "text " with quotes"
The quote needs to be escaped with a backslash.

If the string contains a backslash, it will usually disappear. It needs to be
doubled...

I have a quick & dirty patch for this:
--- confuse-2.5.orig/src/confuse.c
+++ confuse-2.5/src/confuse.c
@@ -1397,7 +1397,18 @@
             break;
         case CFGT_STR:
             str = cfg_opt_getnstr(opt, index);
-            fprintf(fp, "\"%s\"", str ? str : "");
+           fprintf(fp, "\"");
+            while (str && *str) {
+                if (*str == '"') {
+                    fprintf(fp, "\\\"");
+               } else if (*str == '\\') {
+                    fprintf(fp, "\\\\");
+                } else {
+                    fprintf(fp, "%c", *str);
+                }
+                str++;
+            }
+            fprintf(fp, "\"");
             break;
         case CFGT_BOOL:
             fprintf(fp, "%s", cfg_opt_getnbool(opt, index) ? "true" : "false");

Cheers,

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)

Versions of packages libconfuse0 depends on:
ii  libc6                         2.3.6-15   GNU C Library: Shared libraries

libconfuse0 recommends no packages.

-- no debconf information

Reply via email to