Printf format sanitising.

Refactored version for next, use a new helper in
simgear::strutils.
This commit is contained in:
James Turner
2013-09-15 13:30:12 +01:00
parent 0e2ddb2f16
commit a18792c397
3 changed files with 23 additions and 2 deletions
+13
View File
@@ -26,6 +26,8 @@
#include "strutils.hxx"
#include <simgear/debug/logstream.hxx>
using std::string;
using std::vector;
using std::stringstream;
@@ -484,6 +486,17 @@ std::string unescape(const char* s)
return r;
}
string sanitizePrintfFormat(const string& input)
{
string::size_type i = input.find("%n");
if (i != string::npos) {
SG_LOG(SG_IO, SG_WARN, "sanitizePrintfFormat: bad format string:" << input);
return string();
}
return input;
}
} // end namespace strutils
} // end namespace simgear