summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElan Ruusamäe <glen@delfi.ee>2010-05-28 15:16:39 +0000
committerElan Ruusamäe <glen@delfi.ee>2010-05-28 15:16:39 +0000
commit5518643d399db0bdc54ec15ec2cb2528d0ce1ff9 (patch)
tree0e8563924490fe7d21aa26bc40ca9938a36a2803
parentb3892c14108f12cf4aea5cc3449a4be1d9b9d0a2 (diff)
downloadlighttpd-git-5518643d399db0bdc54ec15ec2cb2528d0ce1ff9.tar.gz
- Print double quotes properly when dumping config file (fixes #1806)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2725 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 500019f5..1929715e 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ NEWS
* Fix detecting git repository (fixes #2173, thx ncopa)
* [mod_compress] Fix segfault when etags are disabled (fixes #2169)
* Reset uri.authority before TLS servername handling, reset all "keep-alive" data in connection_del (fixes #2125)
+ * Print double quotes properly when dumping config file (fixes #1806)
- 1.4.26 - 2010-02-07
* Fix request parser to handle packets with splitted \r\n\r\n (fixes #2105)
diff --git a/src/data_string.c b/src/data_string.c
index 919550ba..87a705b4 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);
}