From 6243fe1a2ead97b88f057cd39cff0bbc859e80ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20W=C3=BCst?= Date: Thu, 11 Apr 2024 21:41:02 +0200 Subject: [PATCH] fixed umlaut rendering in news; updated testcase; --- rpm/harbour-watchlist.changes.in | 4 ++++ src/newsdata/ingdibanews.cpp | 1 + test/cpp/watchlisttests.cpp | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/rpm/harbour-watchlist.changes.in b/rpm/harbour-watchlist.changes.in index a4954dd..0f5c9a5 100644 --- a/rpm/harbour-watchlist.changes.in +++ b/rpm/harbour-watchlist.changes.in @@ -5,6 +5,10 @@ # * date Author's Name version-release # - Summary of changes +* xx.xx.2024 Andreas Wüst 0.13.5-1 + +- fixed special character rendering in news (e.g. Johnson & Johnson) + * 04.04.2024 Andreas Wüst 0.13.4-1 - hide dividends payed in the past (for current month) diff --git a/src/newsdata/ingdibanews.cpp b/src/newsdata/ingdibanews.cpp index 4a5444d..4b0db5a 100644 --- a/src/newsdata/ingdibanews.cpp +++ b/src/newsdata/ingdibanews.cpp @@ -112,6 +112,7 @@ QString IngDibaNews::filterContent(QString &content) { QRegExp whiteSpaces("[\\s\\n]+"); content.replace(allTagsRegExp, " "); content.replace(whiteSpaces, " "); + content.replace("&", "&"); return content; } diff --git a/test/cpp/watchlisttests.cpp b/test/cpp/watchlisttests.cpp index f3c11ef..1c1937f 100644 --- a/test/cpp/watchlisttests.cpp +++ b/test/cpp/watchlisttests.cpp @@ -76,14 +76,22 @@ void WatchlistTests::testIngDibaNewsProcessSearchResult() { } void WatchlistTests::testIngDibaNewsFilterContent() { - QString content = "

\n FRANKFURT (Dow Jones)--In der deutschen

\n

\n Die Vereinigten Staaten .. Lage " - "wünschenswert.

\n

\n Kontakt zum Autor: unternehmen.de@dowjones.com

\n

\n DJG/sha " - "

\n

\n (END) Dow Jones Newswires

\n

\n July 04, 2021 11:10 ET (15:10 GMT)

"; - const QString expectedContent + // given + QString content1 + = "

\n FRANKFURT (Dow Jones)--In der deutschen

\n

\n Die Vereinigten Staaten .. Lage " + "wünschenswert.

\n

\n Kontakt zum Autor: unternehmen.de@dowjones.com

\n

\n DJG/sha " + "

\n

\n (END) Dow Jones Newswires

\n

\n July 04, 2021 11:10 ET (15:10 GMT)

"; + const QString expectedContent1 = " FRANKFURT (Dow Jones)--In der deutschen Die Vereinigten Staaten .. Lage wünschenswert. Kontakt zum Autor: " "unternehmen.de@dowjones.com DJG/sha (END) Dow Jones Newswires July 04, 2021 11:10 ET (15:10 GMT) "; - QCOMPARE(ingDibaNews->filterContent(content), expectedContent); + QString content2 = "Johnson & Johnson steigerte"; + const QString expectedContent2 = " Johnson & Johnson steigerte"; + + // when - then + QCOMPARE(ingDibaNews->filterContent(content1), expectedContent1); + QCOMPARE(ingDibaNews->filterContent(content2), expectedContent2); } void WatchlistTests::testDividendDataUpdateWorkerCalculateConvertedAmount() { @@ -104,7 +112,6 @@ void WatchlistTests::testDividendDataUpdateWorkerCalculateConvertedAmount() { QByteArray WatchlistTests::readFileData(const QString &fileName) { QFile f("testdata/" + fileName); if (!f.open(QFile::ReadOnly | QFile::Text)) { - QString msg = "Testfile " + fileName + " not found!"; return QByteArray(); }