projects
/
project
/
uci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add bitfield_set function from libubox.
[project/uci.git]
/
util.c
diff --git
a/util.c
b/util.c
index
09f1817
..
12aec9b
100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-69,18
+69,22
@@
__private char *uci_strdup(struct uci_context *ctx, const char *str)
* for names, only alphanum and _ is allowed (shell compatibility)
* for types, we allow more characters
*/
* for names, only alphanum and _ is allowed (shell compatibility)
* for types, we allow more characters
*/
-__private bool uci_validate_str(const char *str, bool name)
+__private bool uci_validate_str(const char *str, bool name
, bool package
)
{
if (!*str)
return false;
{
if (!*str)
return false;
-
while (*str
) {
+
for (; *str; str++
) {
unsigned char c = *str;
unsigned char c = *str;
- if (!isalnum(c) && c != '_') {
- if (name || (c < 33) || (c > 126))
- return false;
- }
- str++;
+
+ if (isalnum(c) || c == '_')
+ continue;
+
+ if (c == '-' && package)
+ continue;
+
+ if (name || (c < 33) || (c > 126))
+ return false;
}
return true;
}
}
return true;
}
@@
-89,12
+93,10
@@
bool uci_validate_text(const char *str)
{
while (*str) {
unsigned char c = *str;
{
while (*str) {
unsigned char c = *str;
- if (((c < 32) &&
- (c != '\t') &&
- (c != '\n') &&
- (c != '\r'))) {
+
+ if (c < 32 && c != '\t' && c != '\n' && c != '\r')
return false;
return false;
- }
+
str++;
}
return true;
str++;
}
return true;