mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
shell_unescape: fix recently added breakage of decoding escapy strings
This pach fixes two issues (both appear only in escapy strings): * tail cut of escapy string when '\\' is met * head cut of escapy string when '\\' is met :] Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
This commit is contained in:
parent
96fc77bc3e
commit
97bdf084f8
@ -1611,7 +1611,7 @@ shell_unescape(const char* text)
|
||||
result = g_strdup(text);
|
||||
return result;
|
||||
}
|
||||
str = g_string_new("");
|
||||
str = g_string_new_len(text, readptr - text);
|
||||
|
||||
/* if we're here, we're standing on the first '\' */
|
||||
char c;
|
||||
@ -1622,6 +1622,9 @@ shell_unescape(const char* text)
|
||||
readptr++;
|
||||
switch ((c = *readptr))
|
||||
{
|
||||
case '\0': /* end of string! malformed escape string */
|
||||
goto out;
|
||||
|
||||
case 'n': g_string_append_c(str,'\n'); break;
|
||||
case 'r': g_string_append_c(str,'\r'); break;
|
||||
case 't': g_string_append_c(str,'\t'); break;
|
||||
@ -1646,8 +1649,6 @@ shell_unescape(const char* text)
|
||||
case '`':
|
||||
case '"':
|
||||
case ';':
|
||||
case '\0': /* end of string! malformed escape string */
|
||||
goto out;
|
||||
default:
|
||||
g_string_append_c(str,c); break;
|
||||
}
|
||||
@ -1659,7 +1660,6 @@ shell_unescape(const char* text)
|
||||
readptr++;
|
||||
}
|
||||
out:
|
||||
g_string_append_c(str,'\0');
|
||||
|
||||
result = str->str;
|
||||
g_string_free(str,FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user