dastworx, todo list fixes

* fix special char literals for pascal strings not verified when the text doesn't contain a single quote.
* fix len limit not applied correctly
* fix single quote after special char put unconditionally
* prevent loading when deserialization fail
This commit is contained in:
Basile Burg 2019-03-27 17:17:52 +01:00
parent dfac54d407
commit 94c2b5a713
2 changed files with 20 additions and 7 deletions

View File

@ -197,10 +197,14 @@ string patchPascalString(size_t lenLimit = 0)(string value)
{ {
bool needed; bool needed;
foreach(i; 0 .. value.length) foreach(i; 0 .. value.length)
if (value[i] == '\'') switch (value[i])
{ {
needed = true; case '\'' :
break; case '\r' :
case '\n' :
needed = true;
break;
default:
} }
if (!needed) if (!needed)
return value; return value;
@ -212,7 +216,7 @@ string patchPascalString(size_t lenLimit = 0)(string value)
const size_t len = value.length; const size_t len = value.length;
app.reserve(len); app.reserve(len);
bool skip; bool skip;
L: foreach (immutable i; 0..value.length) L: foreach (immutable i; 0..len)
{ {
const char c = value[i]; const char c = value[i];
switch (c) switch (c)
@ -228,7 +232,9 @@ string patchPascalString(size_t lenLimit = 0)(string value)
if (skip) if (skip)
app ~= value[i]; app ~= value[i];
else else
app ~= "'#39'"; app ~= "'#39";
if (i != len-1)
app ~= "'";
skip = false; skip = false;
break; break;
} }
@ -237,7 +243,9 @@ string patchPascalString(size_t lenLimit = 0)(string value)
if (skip) if (skip)
app ~= value[i]; app ~= value[i];
else else
app ~= "'#10'"; app ~= "'#10";
if (i != len-1)
app ~= "'";
skip = false; skip = false;
break; break;
} }

View File

@ -491,7 +491,12 @@ end;
procedure TTodoListWidget.toolTerminated(Sender: TObject); procedure TTodoListWidget.toolTerminated(Sender: TObject);
begin begin
fToolProc.StdoutEx.Position := 0; fToolProc.StdoutEx.Position := 0;
fTodos.loadFromTxtStream(fToolProc.StdoutEx); try
fTodos.loadFromTxtStream(fToolProc.StdoutEx);
except
fToolProc.OnTerminate := nil;
exit;
end;
fillTodoList; fillTodoList;
fToolProc.OnTerminate := nil; fToolProc.OnTerminate := nil;
end; end;