Bugfix: escaped % in format did not work
This commit is contained in:
@ -1073,7 +1073,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
// 1) read a line from protocol source and code quoted strings,
|
||||
// numerical bytes, tokens, etc, and replace variables and parameters
|
||||
// 2) replace the formats in the line
|
||||
// thus variables can be replaces inside the format info string
|
||||
// thus variables can be replaced inside the format info string
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -1088,11 +1088,15 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
int nformats=0;
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
"looking for formats at pos %d in \"%s\"\n", formatpos, buffer.expand(formatpos)());
|
||||
while ((formatpos = buffer.find('%', formatpos)) != -1)
|
||||
char c;
|
||||
while ((c = buffer[formatpos]) != '\0')
|
||||
{
|
||||
if (buffer[formatpos-1] == esc) continue;
|
||||
if (c == esc) {
|
||||
// ignore escaped %
|
||||
formatpos+=2;
|
||||
continue;
|
||||
}
|
||||
if (c == '%') {
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
"format=\"%s\"\n", buffer.expand(formatpos)());
|
||||
nformats++;
|
||||
@ -1113,8 +1117,10 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
"replaced by: \"%s\"\n", buffer.expand(formatpos)());
|
||||
formatpos += formatbuffer.length();
|
||||
continue;
|
||||
}
|
||||
formatpos ++;
|
||||
}
|
||||
formatpos = buffer.length();
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
"%d formats found in line %d\n", nformats, line);
|
||||
}
|
||||
|
Reference in New Issue
Block a user