* Fixed: [ restconf patch method unable to chage value to empty string #229](https://github.com/clicon/clixon/issues/229)

This commit is contained in:
Olof hagsand 2021-06-28 17:33:17 +02:00
parent 3539a80d5e
commit 54357a2a78
2 changed files with 20 additions and 16 deletions

View file

@ -110,6 +110,7 @@ Developers may need to change their code
### Corrected Bugs ### Corrected Bugs
* Fixed: [ restconf patch method unable to chage value to empty string #229](https://github.com/clicon/clixon/issues/229)
* Fixed: [restconf patch method adds redundant namespaces #235](https://github.com/clicon/clixon/issues/235) * Fixed: [restconf patch method adds redundant namespaces #235](https://github.com/clicon/clixon/issues/235)
* Fixed: Restconf HEAD did not work everywhere GET did, such as well-known and exact root. * Fixed: Restconf HEAD did not work everywhere GET did, such as well-known and exact root.
* Fixed: [JSON parsing error for a specific input. #236](https://github.com/clicon/clixon/issues/236) * Fixed: [JSON parsing error for a specific input. #236](https://github.com/clicon/clixon/issues/236)

View file

@ -459,7 +459,7 @@ text_modify(clicon_handle h,
changed++; changed++;
if (op==OP_NONE) if (op==OP_NONE)
xml_flag_set(x0, XML_FLAG_NONE); /* Mark for potential deletion */ xml_flag_set(x0, XML_FLAG_NONE); /* Mark for potential deletion */
if (x1bstr){ /* empty type does not have body */ if (x1bstr){ /* empty type does not have body */ /* XXX Here x0 = <b></b> */
if ((x0b = xml_new("body", x0, CX_BODY)) == NULL) if ((x0b = xml_new("body", x0, CX_BODY)) == NULL)
goto done; goto done;
} }
@ -499,23 +499,26 @@ text_modify(clicon_handle h,
if (assign_namespace_body(x1, x0) < 0) if (assign_namespace_body(x1, x0) < 0)
goto done; goto done;
} }
if ((x0b = xml_body_get(x0)) != NULL){ /* XXX here x1bstr is checked for null, while adding an empty string above */
x0bstr = xml_value(x0b); if ((x0b = xml_body_get(x0)) == NULL && x1bstr && strlen(x1bstr)){
if (x0bstr==NULL || strcmp(x0bstr, x1bstr)){ if ((x0b = xml_new("body", x0, CX_BODY)) == NULL)
if ((op != OP_NONE) && !permit && xnacm){ goto done;
if ((ret = nacm_datanode_write(h, x1, x1t, }
x0bstr==NULL?NACM_CREATE:NACM_UPDATE, x0bstr = xml_value(x0b);
username, xnacm, cbret)) < 0) if (x0bstr==NULL || strcmp(x0bstr, x1bstr)){
goto done; if ((op != OP_NONE) && !permit && xnacm){
if (ret == 0) if ((ret = nacm_datanode_write(h, x1, x1t,
goto fail; x0bstr==NULL?NACM_CREATE:NACM_UPDATE,
} username, xnacm, cbret)) < 0)
if (xml_value_set(x0b, x1bstr) < 0)
goto done; goto done;
/* If a default value ies replaced, then reset default flag */ if (ret == 0)
if (xml_flag(x0, XML_FLAG_DEFAULT)) goto fail;
xml_flag_reset(x0, XML_FLAG_DEFAULT);
} }
if (xml_value_set(x0b, x1bstr) < 0)
goto done;
/* If a default value ies replaced, then reset default flag */
if (xml_flag(x0, XML_FLAG_DEFAULT))
xml_flag_reset(x0, XML_FLAG_DEFAULT);
} }
} /* x1bstr */ } /* x1bstr */
if (changed){ if (changed){