Fix quoting in Linux

We cannot quote UTF-8 chars.
This commit is contained in:
Andrea Mazzoleni 2017-02-24 22:18:45 +01:00
parent 1f76216697
commit 1681f7c9c7
2 changed files with 30 additions and 26 deletions

View file

@ -1,8 +1,9 @@
SnapRAID HISTORY
================
11.1 2017/01
11.1 2017/02
============
* Fixed quoting when printing in Linux. This fixes the UTF-8 output.
* Fixed recognition of 'hashsize' in the configuration file.
The previous incorrect 'hash_size' is still supported for backward
compatibility.

View file

@ -527,32 +527,29 @@ const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer
*p++ = c;
}
break;
default :
/* unquoted */
if (p == end)
goto bail;
*p++ = c;
break;
#else
case 'a' ... 'z' :
case 'A' ... 'Z' :
case '0' ... '9' :
case ',' :
case '.' :
case '_' :
case '+' :
case ':' :
case '@' :
case '%' :
case '/' :
case '-' :
/* safe chars for all shells, unquoted */
if (p == end)
goto bail;
*p++ = c;
break;
default :
/* all the others are quoted with \ */
/* special chars that need to be quoted */
case ' ' : /* space */
case '~' : /* home */
case '`' : /* command */
case '#' : /* comment */
case '$' : /* variable */
case '&' : /* background job */
case '*' : /* wildcard */
case '(' : /* shell */
case ')' : /* shell */
case '\\': /* quote */
case '|' : /* pipe */
case '[' : /* wildcard */
case ']' : /* wildcard */
case '{' : /* code */
case '}' : /* code */
case ';' : /* separator */
case '\'': /* quote */
case '"' : /* quote */
case '<' : /* redirect */
case '>' : /* redirect */
case '?' : /* wildcard */
if (p == end)
goto bail;
*p++ = '\\';
@ -561,6 +558,12 @@ const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer
*p++ = c;
break;
#endif
default :
/* unquoted */
if (p == end)
goto bail;
*p++ = c;
break;
}
++str;