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]);
|
||||
|
||||
//Force xml extension to the file
|
||||
if (xml && !filename.endsWith(".xml", Qt::CaseInsensitive)) {
|
||||
filename+=".xml";
|
||||
if (xml && !filename.endsWith(".xml", Qt::CaseInsensitive))
|
||||
{
|
||||
filename += ".xml";
|
||||
}
|
||||
|
||||
//Force .txt extension
|
||||
if (!xml && !filename.endsWith(".txt", Qt::CaseInsensitive)) {
|
||||
filename+=".txt";
|
||||
if (!xml && !filename.endsWith(".txt", Qt::CaseInsensitive))
|
||||
{
|
||||
filename += ".txt";
|
||||
}
|
||||
|
||||
mResults.Save(filename, xml);
|
||||
|
|
|
@ -128,13 +128,18 @@ std::string ErrorLogger::ErrorMessage::toXML() const
|
|||
// Replace characters in message
|
||||
std::string m(_msg);
|
||||
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] == '<')
|
||||
m.insert(pos + 1, "<");
|
||||
if (m[pos] == '>')
|
||||
else if (m[pos] == '>')
|
||||
m.insert(pos + 1, ">");
|
||||
else if (m[pos] == '&')
|
||||
m.insert(pos + 1, "&");
|
||||
else if (m[pos] == '"')
|
||||
m.insert(pos + 1, """);
|
||||
m.erase(pos, 1);
|
||||
++pos;
|
||||
}
|
||||
|
||||
xml << " msg=\"" << m << "\"";
|
||||
|
|
Loading…
Reference in New Issue