Fix ticket #397 (xml output doesn't encode " and & -characters as it should)
http://sourceforge.net/apps/trac/cppcheck/ticket/397
This commit is contained in:
parent
799252e8f2
commit
9ea80b4d74
|
@ -460,13 +460,15 @@ void MainWindow::Save()
|
||||||
bool xml = (dialog.selectedNameFilter() == filters[0]);
|
bool xml = (dialog.selectedNameFilter() == filters[0]);
|
||||||
|
|
||||||
//Force xml extension to the file
|
//Force xml extension to the file
|
||||||
if (xml && !filename.endsWith(".xml", Qt::CaseInsensitive)) {
|
if (xml && !filename.endsWith(".xml", Qt::CaseInsensitive))
|
||||||
filename+=".xml";
|
{
|
||||||
|
filename += ".xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Force .txt extension
|
//Force .txt extension
|
||||||
if (!xml && !filename.endsWith(".txt", Qt::CaseInsensitive)) {
|
if (!xml && !filename.endsWith(".txt", Qt::CaseInsensitive))
|
||||||
filename+=".txt";
|
{
|
||||||
|
filename += ".txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
mResults.Save(filename, xml);
|
mResults.Save(filename, xml);
|
||||||
|
|
|
@ -128,13 +128,18 @@ std::string ErrorLogger::ErrorMessage::toXML() const
|
||||||
// Replace characters in message
|
// Replace characters in message
|
||||||
std::string m(_msg);
|
std::string m(_msg);
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
while ((pos = m.find_first_of("<>", pos)) != std::string::npos)
|
while ((pos = m.find_first_of("<>&\"", pos)) != std::string::npos)
|
||||||
{
|
{
|
||||||
if (m[pos] == '<')
|
if (m[pos] == '<')
|
||||||
m.insert(pos + 1, "<");
|
m.insert(pos + 1, "<");
|
||||||
if (m[pos] == '>')
|
else if (m[pos] == '>')
|
||||||
m.insert(pos + 1, ">");
|
m.insert(pos + 1, ">");
|
||||||
|
else if (m[pos] == '&')
|
||||||
|
m.insert(pos + 1, "&");
|
||||||
|
else if (m[pos] == '"')
|
||||||
|
m.insert(pos + 1, """);
|
||||||
m.erase(pos, 1);
|
m.erase(pos, 1);
|
||||||
|
++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml << " msg=\"" << m << "\"";
|
xml << " msg=\"" << m << "\"";
|
||||||
|
|
Loading…
Reference in New Issue