mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 19:47:31 +00:00
Added stricter rules to is_valid_project_name ##projects (#18598)
* Only allow lowercase letters, numbers and lowerdash
This commit is contained in:
parent
88c76bc0f1
commit
13bc241a03
@ -12,23 +12,13 @@
|
||||
// project apis to be used from cmd_project.c
|
||||
|
||||
static bool is_valid_project_name(const char *name) {
|
||||
int i;
|
||||
if (r_str_endswith (name, ".zip")) {
|
||||
if (r_str_len_utf8 (name) >= 16) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; name[i]; i++) {
|
||||
switch (name[i]) {
|
||||
case '\\': // for w32
|
||||
case '.':
|
||||
case '_':
|
||||
case ':':
|
||||
case '-':
|
||||
continue;
|
||||
}
|
||||
if (isalpha ((unsigned char)name[i])) {
|
||||
continue;
|
||||
}
|
||||
if (IS_DIGIT (name[i])) {
|
||||
const char *extention = r_str_endswith (name, ".zip") ?
|
||||
r_str_last (name, ".zip") : NULL;
|
||||
for (; *name && name != extention; name++) {
|
||||
if (IS_DIGIT (*name) || IS_LOWER (*name) || *name == '_') {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
|
@ -480,14 +480,14 @@ FILE=malloc://512
|
||||
CMDS=<<EOF
|
||||
e prj.git=false
|
||||
e dir.projects = .tmp/
|
||||
Ps named_prj > /dev/null
|
||||
Ps namedprj > /dev/null
|
||||
e prj.name=
|
||||
Po named_prj > /dev/null
|
||||
Po namedprj > /dev/null
|
||||
e prj.name
|
||||
rm .tmp/named_prj
|
||||
rm .tmp/namedprj
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
named_prj
|
||||
namedprj
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user