LibIMAP: Properly escape the whole string instead of the first character

These were obvious wrong uses of the old default "only first occurence"
parameter that was used in String::replace.
This commit is contained in:
DexesTTP 2022-07-05 22:48:55 +02:00 committed by Linus Groh
parent 6c7ee391cb
commit e371552ff2

View file

@ -128,7 +128,7 @@ String serialize_astring(StringView string)
// Try to quote
auto can_be_quoted = !(string.contains('\n') || string.contains('\r'));
if (can_be_quoted) {
auto escaped_str = string.replace("\\", "\\\\", ReplaceMode::FirstOnly).replace("\"", "\\\"", ReplaceMode::FirstOnly);
auto escaped_str = string.replace("\\", "\\\\", ReplaceMode::All).replace("\"", "\\\"", ReplaceMode::All);
return String::formatted("\"{}\"", escaped_str);
}