@@ -274,11 +274,9 @@ std::string ErrorMessage::serialize() const
274
274
serializeString (oss, severityToString (severity));
275
275
serializeString (oss, std::to_string (cwe.id ));
276
276
serializeString (oss, std::to_string (hash));
277
+ serializeString (oss, fixInvalidChars (remark));
277
278
serializeString (oss, file0);
278
- if (certainty == Certainty::inconclusive) {
279
- const std::string text (" inconclusive" );
280
- serializeString (oss, text);
281
- }
279
+ serializeString (oss, (certainty == Certainty::inconclusive) ? " 1" : " 0" );
282
280
283
281
const std::string saneShortMessage = fixInvalidChars (mShortMessage );
284
282
const std::string saneVerboseMessage = fixInvalidChars (mVerboseMessage );
@@ -312,9 +310,9 @@ void ErrorMessage::deserialize(const std::string &data)
312
310
callStack.clear ();
313
311
314
312
std::istringstream iss (data);
315
- std::array<std::string, 7 > results;
313
+ std::array<std::string, 9 > results;
316
314
std::size_t elem = 0 ;
317
- while (iss.good () && elem < 7 ) {
315
+ while (iss.good () && elem < 9 ) {
318
316
unsigned int len = 0 ;
319
317
if (!(iss >> len))
320
318
throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - invalid length" );
@@ -332,11 +330,6 @@ void ErrorMessage::deserialize(const std::string &data)
332
330
333
331
if (!iss.good ())
334
332
throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - premature end of data" );
335
-
336
- if (temp == " inconclusive" ) {
337
- certainty = Certainty::inconclusive;
338
- continue ;
339
- }
340
333
}
341
334
342
335
results[elem++] = std::move (temp);
@@ -345,7 +338,7 @@ void ErrorMessage::deserialize(const std::string &data)
345
338
if (!iss.good ())
346
339
throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - premature end of data" );
347
340
348
- if (elem != 7 )
341
+ if (elem != 9 )
349
342
throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - insufficient elements" );
350
343
351
344
id = std::move (results[0 ]);
@@ -362,9 +355,12 @@ void ErrorMessage::deserialize(const std::string &data)
362
355
if (!strToInt (results[3 ], hash, &err))
363
356
throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - invalid hash - " + err);
364
357
}
365
- file0 = std::move (results[4 ]);
366
- mShortMessage = std::move (results[5 ]);
367
- mVerboseMessage = std::move (results[6 ]);
358
+ remark = std::move (results[4 ]);
359
+ file0 = std::move (results[5 ]);
360
+ if (results[6 ] == " 1" )
361
+ certainty = Certainty::inconclusive;
362
+ mShortMessage = std::move (results[7 ]);
363
+ mVerboseMessage = std::move (results[8 ]);
368
364
369
365
unsigned int stackSize = 0 ;
370
366
if (!(iss >> stackSize))
@@ -496,6 +492,9 @@ std::string ErrorMessage::toXML() const
496
492
if (!file0.empty ())
497
493
printer.PushAttribute (" file0" , file0.c_str ());
498
494
495
+ if (!remark.empty ())
496
+ printer.PushAttribute (" remark" , fixInvalidChars (remark).c_str ());
497
+
499
498
for (std::list<FileLocation>::const_reverse_iterator it = callStack.crbegin (); it != callStack.crend (); ++it) {
500
499
printer.OpenElement (" location" , false );
501
500
printer.PushAttribute (" file" , it->getfile ().c_str ());
@@ -641,6 +640,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
641
640
findAndReplace (result, " {severity}" , severityToString (severity));
642
641
findAndReplace (result, " {cwe}" , std::to_string (cwe.id ));
643
642
findAndReplace (result, " {message}" , verbose ? mVerboseMessage : mShortMessage );
643
+ findAndReplace (result, " {remark}" , remark);
644
644
if (!callStack.empty ()) {
645
645
if (result.find (" {callstack}" ) != std::string::npos)
646
646
findAndReplace (result, " {callstack}" , ErrorLogger::callStackToString (callStack));
0 commit comments