From 8fe79459def2208541dd7f202da1fda50316858b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 8 Apr 2026 03:44:32 +0000 Subject: [PATCH] Deploy d6b111f from main --- includes/class-peptide-news-rest-api.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/class-peptide-news-rest-api.php b/includes/class-peptide-news-rest-api.php index d53c7af..90c7dc9 100644 --- a/includes/class-peptide-news-rest-api.php +++ b/includes/class-peptide-news-rest-api.php @@ -236,7 +236,7 @@ class Peptide_News_Rest_API { } } - // Fallback: strip trailing " - Short Publisher Name" patterns (1-5 words). + // Fallback 1: strip trailing " - Short Publisher Name" patterns (1-5 words). // Only strips if the part after the separator looks like a publisher name // (starts with uppercase, no sentence-ending punctuation). $pattern = '/\s+[-\x{2013}\x{2014}|]\s+[A-Z][A-Za-z0-9\s.\'\-]{0,50}$/u'; @@ -245,6 +245,15 @@ class Peptide_News_Rest_API { return rtrim( $candidate ); } + // Fallback 2: strip trailing nbsp-separated publisher names. + // Google News RSS excerpts use double non-breaking space + publisher name + // when the source field doesn't match (e.g., source = "news.google.com"). + $nbsp_pattern = '/(?:\x{00A0}{1,2}|\s{2,})[A-Z][A-Za-z0-9\s.\'\-]{0,50}$/u'; + $candidate = preg_replace( $nbsp_pattern, '', $text ); + if ( $candidate !== $text && strlen( $candidate ) > strlen( $text ) * 0.4 ) { + return rtrim( $candidate ); + } + return $text; }