summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglen <glen@152afb58-edef-0310-8abb-c4023f1b3aa9>2010-05-28 15:36:44 +0000
committerglen <glen@152afb58-edef-0310-8abb-c4023f1b3aa9>2010-05-28 15:36:44 +0000
commit051f35ba6c65cc022727e18fa8b5aa13f2fc0e5c (patch)
tree5841b574cd1b19e89736d3c07f936709b15fc0c3
parent6e549649832476f1fe1fb1f9843e2504e5b3b35a (diff)
downloadlighttpd-051f35ba6c65cc022727e18fa8b5aa13f2fc0e5c.tar.gz
- Print double quotes properly when dumping config file (fixes #1806)
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@2726 152afb58-edef-0310-8abb-c4023f1b3aa9
-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);
}