From 128062823ecbe45fa476ab28b145cea83cd365b9 Mon Sep 17 00:00:00 2001
From: slioch <slioch@eng-140.vyatta.com>
Date: Mon, 6 Oct 2008 15:50:50 -0700
Subject: fix for bug 3666. strip off leading and trailing quote from default
 text values that are deleted. default values are treated differently from
 hollywood. The main difference a script writer needs to be aware of is that a
 deleted node will set the value of the node back to the default value rather
 than deleting the node.

This means that a node that has a default value will always be in existence (if the parent exists) and that a user cannot
delete this node.
---
 src/delete.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/delete.c b/src/delete.c
index 6fe4eb3..57235d6 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -78,6 +78,20 @@ static void reset_default(const char *def_val)
   if (def_val == NULL)
     return;
 
+  //strip off quotes
+  char tmp_val[1025];
+  char *ptr = index(def_val,'"');
+  if (ptr != NULL) {
+    strcpy(tmp_val,ptr);
+    ptr = rindex(tmp_val,'"');
+    if (ptr != NULL) {
+      *ptr = '\0';
+    }
+  }
+  else {
+    strcpy(tmp_val,def_val);
+  }
+
   char filename[strlen(m_path.path) + 10];
   touch();
   sprintf(filename, "%s/node.val", m_path.path);
@@ -85,7 +99,7 @@ static void reset_default(const char *def_val)
   FILE *fp = fopen(filename, "w");
   if (fp == NULL)
     bye("can not open: %s", filename);
-  fputs(def_val, fp);
+  fputs(tmp_val, fp);
   fclose(fp);
 
   sprintf(filename, "%s/def", m_path.path);
-- 
cgit v1.2.3


From d84444065bd1c05de86012910c16cdf12f95f505 Mon Sep 17 00:00:00 2001
From: slioch <slioch@eng-140.vyatta.com>
Date: Tue, 7 Oct 2008 10:30:47 -0700
Subject: fix for regression bug 3758. added additional check requiring opening
 and closing quotes before stripping takes place.

---
 src/delete.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/delete.c b/src/delete.c
index 57235d6..3011c12 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -82,11 +82,14 @@ static void reset_default(const char *def_val)
   char tmp_val[1025];
   char *ptr = index(def_val,'"');
   if (ptr != NULL) {
-    strcpy(tmp_val,ptr);
+    strcpy(tmp_val,ptr+1);
     ptr = rindex(tmp_val,'"');
     if (ptr != NULL) {
       *ptr = '\0';
     }
+    else {
+      strcpy(tmp_val,def_val); //go with original value.
+    }
   }
   else {
     strcpy(tmp_val,def_val);
-- 
cgit v1.2.3