api: fix handle of invalid escape in function string_convert_escaped_chars()

And a new test is now checking that "\" returns "".
v2.8-utf8proc
Sébastien Helleu 2015-08-24 11:05:31 +02:00
parent c8ac75601f
commit 41cb1bf635
3 changed files with 8 additions and 3 deletions

View File

@ -29,6 +29,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* core: fix truncated messages after a word with a length of zero on screen
(for example a zero width space: U+200B) (bug #40985, issue #502)
* api: fix handle of invalid escape in function string_convert_escaped_chars()
* irc: display the arrow before server name in raw buffer
* irc: fix display of messages sent to server in raw buffer
* irc: fix display of invalid UTF-8 chars in raw buffer

View File

@ -787,9 +787,12 @@ string_convert_escaped_chars (const char *string)
}
break;
default:
output[pos_output++] = '\\';
output[pos_output++] = ptr_string[0];
ptr_string++;
if (ptr_string[0])
{
output[pos_output++] = '\\';
output[pos_output++] = ptr_string[0];
ptr_string++;
}
break;
}
}

View File

@ -460,6 +460,7 @@ TEST(String, ConvertEscapedChars)
WEE_TEST_STR(NULL, string_convert_escaped_chars (NULL));
WEE_TEST_STR("", string_convert_escaped_chars (""));
WEE_TEST_STR("", string_convert_escaped_chars ("\\"));
WEE_TEST_STR("\"", string_convert_escaped_chars ("\\\""));
WEE_TEST_STR("\\", string_convert_escaped_chars ("\\\\"));
WEE_TEST_STR("\a", string_convert_escaped_chars ("\\a"));