Bugfixes: escaped quotes in strings and multi-line format strings

This commit is contained in:
zimoch
2010-12-02 16:04:15 +00:00
parent fd0fccda46
commit 2c7391602a

View File

@ -520,7 +520,7 @@ Each time newline is read, line is incremented.
break; break;
} }
buffer.append(c); buffer.append(c);
if (c == quote && buffer[-1] != '\\') if (c == quote && buffer[-2] != '\\')
{ {
quote = false; quote = false;
break; break;
@ -1074,6 +1074,8 @@ compileString(StreamBuffer& buffer, const char*& source,
while (1) while (1)
{ {
debug("StreamProtocolParser::Protocol::compileString "
"buffer so far: %s\n", buffer.expand()());
// this is step 2: replacing the formats // this is step 2: replacing the formats
if (!*source || (newline = getLineNumber(source)) != line) if (!*source || (newline = getLineNumber(source)) != line)
{ {
@ -1082,11 +1084,15 @@ compileString(StreamBuffer& buffer, const char*& source,
// have been replaced and after string has been coded. // have been replaced and after string has been coded.
if (formatType != NoFormat) 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) while ((formatpos = buffer.find('%', formatpos)) != -1)
{ {
if (buffer[formatpos-1] == esc) continue; if (buffer[formatpos-1] == esc) continue;
debug("StreamProtocolParser::Protocol::compileString " debug("StreamProtocolParser::Protocol::compileString "
"format=\"%s\"\n", buffer.expand(formatpos)()); "format=\"%s\"\n", buffer.expand(formatpos)());
nformats++;
formatbuffer.clear(); formatbuffer.clear();
const char* p = buffer(formatpos); const char* p = buffer(formatpos);
if (!compileFormat(formatbuffer, p, formatType, client)) if (!compileFormat(formatbuffer, p, formatType, client))
@ -1105,8 +1111,9 @@ compileString(StreamBuffer& buffer, const char*& source,
"replaced by: \"%s\"\n", buffer.expand(formatpos)()); "replaced by: \"%s\"\n", buffer.expand(formatpos)());
formatpos += formatbuffer.length(); formatpos += formatbuffer.length();
} }
formatpos = buffer.length();
debug("StreamProtocolParser::Protocol::compileString " debug("StreamProtocolParser::Protocol::compileString "
"all formats in line %d found\n", line); "%d formats found in line %d\n", nformats, line);
} }
if (!*source) break; if (!*source) break;
line = newline; line = newline;