forked from github/server
fix some more issues with buffer ending before decisions are finished.
This commit is contained in:
parent
b1cd9bcfef
commit
90b80aba89
2 changed files with 27 additions and 1 deletions
|
@ -144,7 +144,21 @@ static enum OP_Status parse_buffer(OP_Parser parser, int isFinal)
|
|||
}
|
||||
else {
|
||||
/* this is not multi-line input yet, so do nothing */
|
||||
pos = strpbrk(pos + 1, "\\;\n");
|
||||
if (pos[1] == '\0') {
|
||||
/* end of available input */
|
||||
if (isFinal) {
|
||||
/* input ends on a pointless backslash, kill it */
|
||||
pos[0] = '\0';
|
||||
pos = NULL;
|
||||
}
|
||||
else {
|
||||
/* backslash is followed by data that we do not know */
|
||||
pos = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pos = strpbrk(pos + 1, "\\;\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ';':
|
||||
|
|
|
@ -32,27 +32,39 @@ static void test_parse_orders(CuTest *tc) {
|
|||
OP_SetUserData(parser, lastline);
|
||||
OP_SetOrderHandler(parser, copy_line);
|
||||
CuAssertPtrNotNull(tc, parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello World", 11, 1));
|
||||
CuAssertStrEquals(tc, "Hello World", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello World\n", 12, 1));
|
||||
CuAssertStrEquals(tc, "Hello World", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello\\\n World", 13, 1));
|
||||
CuAssertStrEquals(tc, "Hello World", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello;World", 11, 1));
|
||||
CuAssertStrEquals(tc, "Hello", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello\\World", 11, 1));
|
||||
CuAssertStrEquals(tc, "Hello\\World", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello ", 6, 0));
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "World", 5, 1));
|
||||
CuAssertStrEquals(tc, "Hello World", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello\\World \\", 14, 1));
|
||||
CuAssertStrEquals(tc, "Hello\\World ", lastline);
|
||||
OP_ParserReset(parser);
|
||||
lastline[0] = 0;
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "Hello \\", 7, 0));
|
||||
CuAssertIntEquals(tc, OP_STATUS_OK, OP_Parse(parser, "\nWorld", 6, 1));
|
||||
CuAssertStrEquals(tc, "Hello World", lastline);
|
||||
OP_ParserFree(parser);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue