summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/data_string.c19
2 files changed, 19 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0b79b8e9..ea49e397 100644
--- a/NEWS
+++ b/NEWS
@@ -161,6 +161,7 @@ NEWS
* Fix select() backend under high load (off-by-one, noticed by Manuel Scharf in a forum thread)
* Append to previous buffer in con read (fixes #2147, found by liming, CVE-2010-0295)
* Fix handling return value of SSL_CTX_set_options (fixes #2157, thx mlcreech)
+ * Print double quotes properly when dumping config file (fixes #1806)
- 1.5.0-r19.. -
* -F option added for spawn-fcgi
diff --git a/src/data_string.c b/src/data_string.c
index 5b2678d8..a4bc31cf 100644
--- a/src/data_string.c
+++ b/src/data_string.c
@@ -70,8 +70,25 @@ static int data_response_insert_dup(data_unset *dst, data_unset *src) {
static void data_string_print(const data_unset *d, int depth) {
data_string *ds = (data_string *)d;
UNUSED(depth);
+ unsigned int i = 0;
- fprintf(stdout, "\"%s\"", ds->value->used ? ds->value->ptr : "");
+ // empty and uninitialized strings
+ if (ds->value->used < 1) {
+ fputs("\"\"", stdout);
+ return;
+ }
+
+ // print out the string as is, except prepend " with backslash
+ putc('"', stdout);
+ for (i = 0; i < ds->value->used - 1; i++) {
+ unsigned char c = ds->value->ptr[i];
+ if (c == '"') {
+ fputs("\\\"", stdout);
+ } else {
+ putc(c, stdout);
+ }
+ }
+ putc('"', stdout);
}