fix: nbsp-Dekodierung + Malformed-Input-Test im Truth-Parser (Review Task 5)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,14 @@ describe('parseTruthFeed', () => {
|
||||
expect(posts[0].text).toContain('Bitcoin is going to the MOON');
|
||||
expect(posts[0].text).not.toContain('<p>');
|
||||
});
|
||||
test('überspringt malformed Items, leerer Input → []', () => {
|
||||
expect(parseTruthFeed('')).toEqual([]);
|
||||
const bad = `<rss><channel>
|
||||
<item><pubDate>Fri, 12 Jun 2026 01:49:56 +0000</pubDate><description>ohne Link</description></item>
|
||||
<item><link>https://trumpstruth.org/statuses/3</link><pubDate>kein Datum</pubDate><description>x</description></item>
|
||||
</channel></rss>`;
|
||||
expect(parseTruthFeed(bad)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchCoins', () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ export function parseTruthFeed(xml: string): TruthPost[] {
|
||||
const text = descRaw
|
||||
.replace(/^<!\[CDATA\[|\]\]>$/g, '')
|
||||
.replace(/<[^>]+>/g, ' ')
|
||||
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'")
|
||||
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
posts.push({ url, ts, text });
|
||||
|
||||
Reference in New Issue
Block a user