Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19131 closed defect (wontfix)

uci does not allow empty string as an option value

Reported by: anonymous Owned by: developers
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: Cc:

Description

diff -rubp a/list.c b/list.c
--- a/list.c	2014-12-25 14:24:52.000000000 +0100
+++ b/list.c	2015-03-10 10:56:52.103593182 +0100
@@ -679,7 +679,7 @@ int uci_set(struct uci_context *ctx, str
 		if (e)
 			ptr->o = uci_to_option(e);
 	}
-	if (!ptr->value[0]) {
+	if (!ptr->value[0] && !ptr->o && !ptr->s) {
 		/* if setting a nonexistant option/section to a nonexistant value,
 		 * exit without errors */
 		if (!(ptr->flags & UCI_LOOKUP_COMPLETE))

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by jow

  • Resolution set to wontfix
  • Status changed from new to closed

This is correct intentional behaviour as the shell API cannot differentiate between empty string and unset option.

comment:2 Changed 3 years ago by anonymous

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Then you should make it able to distinguish unset option with
ptr->value = NULL

diff -rubp a/list.c b/list.c
--- a/list.c	2014-12-25 14:24:52.000000000 +0100
+++ b/list.c	2015-03-10 10:56:52.103593182 +0100
@@ -679,7 +679,7 @@ int uci_set(struct uci_context *ctx, str
 		if (e)
 			ptr->o = uci_to_option(e);
 	}
-	if (!ptr->value[0]) {
+	if (!ptr->value && !ptr->o && !ptr->s) {
 		/* if setting a nonexistant option/section to a nonexistant value,
 		 * exit without errors */
 		if (!(ptr->flags & UCI_LOOKUP_COMPLETE))}}}

comment:4 Changed 3 years ago by jow

  • Resolution set to wontfix
  • Status changed from reopened to closed

Since this is a) a change request and not a bug and b) alters the behaviour of the api, you should take this discussion to the OpenWrt-Devel mailing list. Please do not reopen this ticket.

comment:5 Changed 3 years ago by anonymous

a) It was working in Attitude Adjustment
b) LuCI has boolean Option attribute rmempty which relies on this old API
c) read the uci author's comment in the code, what he was intending to do, but made a mistake

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.