Repository navigation
Fix #15107: Exporting XML via GUI escapes special characters twice. #8943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,4 +23,5 @@ class TestXmlReportV2 : public QObject { | |
|
|
||
| private slots: | ||
| void readXml() const; | ||
| void writeXmlEscaping() const; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,17 +42,11 @@ class XmlReport : public Report { | |
| */ | ||
| virtual QList<ErrorItem> read() = 0; | ||
|
|
||
| /** | ||
| * @brief Quote the message. | ||
| * @param message Message to quote. | ||
| * @return quoted message. | ||
| */ | ||
| static QString quoteMessage(const QString &message); | ||
|
|
||
| /** | ||
| * @brief Unquote the message. | ||
| * @param message Message to quote. | ||
| * @return quoted message. | ||
| * For older reports where special characters have been escaped twice (#15107). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI review This comment says the function is for older reports, but |
||
| * @param message Message to unquote. | ||
| * @return unquoted message. | ||
| */ | ||
| static QString unquoteMessage(const QString &message); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,10 +132,8 @@ void XmlReportV2::writeError(const ErrorItem &error) | |
|
|
||
| // Don't localize severity so we can read these files | ||
| mXmlWriter->writeAttribute(SeverityAttribute, GuiSeverity::toString(error.severity)); | ||
| const QString summary = XmlReport::quoteMessage(error.summary); | ||
| mXmlWriter->writeAttribute(MsgAttribute, summary); | ||
| const QString message = XmlReport::quoteMessage(error.message); | ||
| mXmlWriter->writeAttribute(VerboseAttribute, message); | ||
| mXmlWriter->writeAttribute(MsgAttribute, error.summary); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI review Now that the attribute is escaped only once, the reader at line 230 still calls |
||
| mXmlWriter->writeAttribute(VerboseAttribute, error.message); | ||
| if (error.inconclusive) | ||
| mXmlWriter->writeAttribute(InconclusiveAttribute, "true"); | ||
| if (!error.remark.isEmpty()) | ||
|
|
@@ -145,7 +143,7 @@ void XmlReportV2::writeError(const ErrorItem &error) | |
| if (error.hash > 0) | ||
| mXmlWriter->writeAttribute(HashAttribute, QString::number(error.hash)); | ||
| if (!error.file0.isEmpty()) | ||
| mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, quoteMessage(error.file0)); | ||
| mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, error.file0); | ||
| if (!error.sinceDate.isEmpty()) | ||
| mXmlWriter->writeAttribute(SinceDateAttribute, error.sinceDate); | ||
| if (!error.tags.isEmpty()) | ||
|
|
@@ -155,12 +153,12 @@ void XmlReportV2::writeError(const ErrorItem &error) | |
| mXmlWriter->writeStartElement(LocationElementName); | ||
|
|
||
| QString file = QDir::toNativeSeparators(error.errorPath[i].file); | ||
| mXmlWriter->writeAttribute(FilenameAttribute, XmlReport::quoteMessage(file)); | ||
| mXmlWriter->writeAttribute(FilenameAttribute, file); | ||
| mXmlWriter->writeAttribute(LineAttribute, QString::number(error.errorPath[i].line)); | ||
| if (error.errorPath[i].column > 0) | ||
| mXmlWriter->writeAttribute(ColumnAttribute, QString::number(error.errorPath[i].column)); | ||
| if (error.errorPath.count() > 1) | ||
| mXmlWriter->writeAttribute(InfoAttribute, XmlReport::quoteMessage(error.errorPath[i].info)); | ||
| mXmlWriter->writeAttribute(InfoAttribute, error.errorPath[i].info); | ||
|
|
||
| mXmlWriter->writeEndElement(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI review
The round-trip check passes only because the string has no literal entity. With e.g.
item.summary = "x < y", theQCOMPARE(errors[0].summary, item.summary)below would fail, becauseunquoteMessageturns the text that was read intox < y.