diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-02 18:37:22 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-06 12:43:06 +0900 |
| commit | bb099158e6c9fd0f1c2771cb9350d3b0a0b51a27 (patch) | |
| tree | 598156ab1f71ee857c8e1f233f0292e13f36fa28 /src/plugins/rssfeed/rss/tools_p.cpp | |
| parent | 7271fa27ac1881beb5326ca8c9c83471695d8487 (diff) | |
| download | ktorrent-bb099158.tar.gz ktorrent-bb099158.zip | |
Restructure source files into 'src' subfolder
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8)
Diffstat (limited to 'src/plugins/rssfeed/rss/tools_p.cpp')
| -rw-r--r-- | src/plugins/rssfeed/rss/tools_p.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/plugins/rssfeed/rss/tools_p.cpp b/src/plugins/rssfeed/rss/tools_p.cpp new file mode 100644 index 0000000..e608f04 --- /dev/null +++ b/src/plugins/rssfeed/rss/tools_p.cpp @@ -0,0 +1,49 @@ +/* + * tools_p.cpp + * + * Copyright (c) 2001, 2002, 2003 Frerich Raabe <raabe@kde.org> + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. For licensing and distribution details, check the + * accompanying file 'COPYING'. + */ +#include "tools_p.h" + +#include <krfcdate.h> +#include <tqdom.h> + +time_t RSS::parseISO8601Date(const TQString &s) +{ + // do some sanity check: 26-12-2004T00:00+00:00 is parsed to epoch+1 in the KRFCDate, which is wrong. So let's check if the date begins with YYYY -fo + if (s.stripWhiteSpace().left(4).toInt() < 1000) + return 0; // error + + // FIXME: imho this is done in KRFCDate::parseDateISO8601() automatically, so we could omit it? -fo + if (s.find('T') != -1) + return KRFCDate::parseDateISO8601(s); + else + return KRFCDate::parseDateISO8601(s + "T12:00:00"); +} + + +TQString RSS::extractNode(const TQDomNode &parent, const TQString &elemName, bool isInlined) +{ + TQDomNode node = parent.namedItem(elemName); + if (node.isNull()) + return TQString(); + + TQString result = node.toElement().text(); + + bool hasPre = result.contains("<pre>",false); + bool hasHtml = hasPre || result.contains("<"); // FIXME: test if we have html, should be more clever -> regexp + if(!isInlined && !hasHtml) // perform nl2br if not a inline elt and it has no html elts + result = result = result.replace(TQChar('\n'), "<br />"); + if(!hasPre) // strip white spaces if no <pre> + result = result.simplifyWhiteSpace(); + + if (result.isEmpty()) + return TQString(); + + return result; +} |
