fix(news): unwrap CDATA titles at ingest and on /api/news

Excelsior rows store the feed's CDATA wrapper as the title text, including
the surrounding whitespace. Strip a whole-title wrapper before insert and
again on GET /api/news so existing rows read clean without an UPDATE.
Plain titles and real HTML are unchanged.
This commit is contained in:
Sirius DevOps 2026-11-14 00:47:04 -05:00
commit 13a4049137
6 changed files with 154 additions and 1 deletions

View file

@ -9,6 +9,8 @@ import psycopg2
import os
from scrapy.exceptions import DropItem
from newsScraper.feed_util import unwrap_cdata_title
log = logging.getLogger(__name__)
# Feed items dated further ahead than this are event listings (or clock skew
@ -104,6 +106,7 @@ class PostgresPipeline:
if url in self.seen_urls:
raise DropItem(f"Duplicate URL (in-memory): {url}")
self.seen_urls.add(url)
item['title'] = unwrap_cdata_title(item['title'])
try:
self.cur.execute("""
INSERT INTO articles (title, url, content, domain, timestamp)