Skip to content

Commit

Permalink
More error message sanitization.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfellows committed Jul 26, 2024
1 parent 695129d commit e0a106d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/moja.modules.cbm/src/flatrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "moja/modules/cbm/flatrecord.h"
#include "moja/hash.h"
#include "moja/logging.h"

namespace moja {
namespace modules {
Expand Down Expand Up @@ -289,12 +288,16 @@ namespace cbm {
auto classifierStr = FlatRecordHelper::BuildClassifierValueString(_classifierValues, csvFormat);
std::string errorStr = _error;

boost::replace_all(errorStr, "\r", " ");
boost::replace_all(errorStr, "\n", " ");
boost::replace_all(errorStr, "\\", "\\\\");

if (csvFormat) {
boost::replace_all(errorStr, "\"", "'");
} else {
boost::replace_all(errorStr, "'", "''");
}
MOJA_LOG_INFO << errorStr;

return (boost::format(csvFormat ? csvRecord : dbRecord)
% _year % classifierStr % _module % errorStr % _area).str();
}
Expand Down

0 comments on commit e0a106d

Please sign in to comment.