Made -getfacl file name escaping more similar to shell command behavior

This commit is contained in:
2009-01-28 19:01:47 +00:00
parent b0aae62aff
commit beac765f7b
4 changed files with 71 additions and 18 deletions

View File

@ -631,6 +631,8 @@ ex:;
/* @param flag bit0= only encode inside quotes
bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13
bit2= encode in any case above 126
bit3= encode in any case shellsafe:
<=42 , 59, 60, 62, 63, 92, 94, 96, >=123
*/
int Sfile_bsl_encoder(char **result, char *text, int flag)
{
@ -640,9 +642,14 @@ int Sfile_bsl_encoder(char **result, char *text, int flag)
count= 0;
for(rpt= text; *rpt != 0; rpt++) {
count++;
if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\')
if(flag & 8) {
if(!(*rpt <= 42 || *rpt == 59 || *rpt == 60 || *rpt == 62 ||
*rpt == 63 || *rpt == 92 || *rpt == 94 || *rpt == 96 ||
*rpt >= 123))
continue;
if((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\')
} else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\')
continue;
if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag & 8))
count++;
else
count+= 3;
@ -655,21 +662,28 @@ int Sfile_bsl_encoder(char **result, char *text, int flag)
sq_open= !(sq_open || dq_open);
if(*rpt == '"')
dq_open= !(sq_open || dq_open);
if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') {
if(flag & 8) {
if(!(*rpt <= 42 || *rpt == 59 || *rpt == 60 || *rpt == 62 ||
*rpt == 63 || *rpt == 92 || *rpt == 94 || *rpt == 96 ||
*rpt >= 123)) {
*(wpt++)= *rpt;
continue;
}
} else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') {
*(wpt++)= *rpt;
continue;
}
if( ((flag & 1) && !(sq_open || dq_open)) &&
!((flag & 2) && (*rpt >= 1 && * rpt <= 31 &&
!(*rpt == 7 || *rpt == 8 || *rpt == 9 || *rpt == 10 ||
*rpt == 12 || *rpt == 13))) &&
!((flag & 4) && (*rpt > 126 || *rpt < 0)) &&
!((flag & 6) && *rpt == '\\')) {
} else if( ((flag & 1) && !(sq_open || dq_open)) &&
!((flag & 2) && (*rpt >= 1 && * rpt <= 31 &&
!(*rpt == 7 || *rpt == 8 || *rpt == 9 || *rpt == 10 ||
*rpt == 12 || *rpt == 13))) &&
!((flag & 4) && (*rpt > 126 || *rpt < 0)) &&
!((flag & 6) && *rpt == '\\')) {
*(wpt++)= *rpt;
continue;
}
*(wpt++)= '\\';
if((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') {
if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag&8)) {
if(*rpt == 7)
*(wpt++)= 'a';
else if(*rpt == 8)
@ -15386,6 +15400,22 @@ ex:;
}
/* Options -setfacl_list alias -setfacl_listi */
int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag)
{
/* >>> Open path */;
/* >>> Loop over lines */;
/* >>> if(strncmp(line, */;
/* >>> */;
/* >>> */;
/* >>> */;
/* >>> */;
return(1);
}
/* Options -setfacl alias -setfacli, -setfacl_r alias -setfacl_ri */
/* @param flag bit0=recursive -setfacl_r
*/
@ -15972,7 +16002,8 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
"setfacl","setfacli","setfacl_r","setfacl_ri",
"setfacl","setfacli","setfacl_list","setfacl_listi",
"setfacl_r","setfacl_ri",
""
};
@ -16602,6 +16633,10 @@ next_command:;
(*idx)+= 1;
ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 0);
} else if(strcmp(cmd,"setfacl_list")==0 || strcmp(cmd,"setfacl_listi")==0) {
(*idx)+= 1;
ret= Xorriso_option_setfacl_listi(xorriso, arg1, 0);
} else if(strcmp(cmd,"setfacl_r")==0 || strcmp(cmd,"setfacl_ri")==0) {
(*idx)+= 1;
ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 1);