Skip to content

Commit

Permalink
Use QDomDocument content method returning ParseResult
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>

Use ParseResult returning QDomDocument setContent

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>

f parseresult

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
  • Loading branch information
claucambra committed Nov 28, 2024
1 parent afc56ad commit f2c2527
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/gui/updater/updateinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ UpdateInfo UpdateInfo::parseElement(const QDomElement &element, bool *ok)

UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok)
{
QString errorMsg;
int errorLine = 0, errorCol = 0;
QDomDocument doc;
if (!doc.setContent(xml, false, &errorMsg, &errorLine, &errorCol)) {
qCWarning(lcUpdater).noquote().nospace() << errorMsg << " at " << errorLine << "," << errorCol
<< "\n" << xml.split("\n").value(errorLine-1) << "\n"
<< QString(" ").repeated(errorCol - 1) << "^\n"
if (const auto result = doc.setContent(xml); !result) {
qCWarning(lcUpdater).noquote().nospace() << result.errorMessage << " at " << result.errorLine << "," << result.errorColumn
<< "\n" << xml.split("\n").value(result.errorLine - 1) << "\n"
<< QString(" ").repeated(result.errorColumn - 1) << "^\n"
<< "->" << xml << "<-";
if (ok)
*ok = false;
Expand Down
7 changes: 2 additions & 5 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,9 @@ bool PropfindJob::finished()
if (http_result_code == 207) {
// Parse DAV response
auto domDocument = QDomDocument();
auto errorMsg = QString();
auto errorLine = -1;
auto errorColumn = -1;

if (!domDocument.setContent(reply(), true, &errorMsg, &errorLine, &errorColumn)) {
qCWarning(lcPropfindJob) << "XML parser error: " << errorMsg << errorLine << errorColumn;
if (const auto res = domDocument.setContent(reply(), QDomDocument::ParseOption::UseNamespaceProcessing); !res) {
qCWarning(lcPropfindJob) << "XML parser error: " << res.errorMessage << res.errorLine << res.errorColumn;
emit finishedWithError(reply());

} else {
Expand Down

0 comments on commit f2c2527

Please sign in to comment.