A free, self-hostable news aggregator…
API protection limit content size (#4583)
Alexandre Alapetite3b81708c1aa7
diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex feb094347..12cef68a5 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -651,6 +651,12 @@ class FreshRSS_Entry extends Minz_Model {str_pad(dechex($dec), 16, '0', STR_PAD_LEFT);}+ /**+ * Some clients (tested with News+) would fail if sending too long item content+ * @var int+ */+ const API_MAX_COMPAT_CONTENT_LENGTH = 500000;+/*** N.B.: To avoid expensive lookups, ensure to set `$entry->_feed($feed)` before calling this function.* N.B.: You might have to populate `$entry->_tags()` prior to calling this function.@@ -690,6 +696,9 @@ class FreshRSS_Entry extends Minz_Model {if ($mode === 'compat') {$item['title'] = escapeToUnicodeAlternative($this->title(), false);unset($item['alternate'][0]['type']);+ if (mb_strlen($this->content(), 'UTF-8') > self::API_MAX_COMPAT_CONTENT_LENGTH) {+ $item['summary']['content'] = mb_strcut($this->content(), 0, self::API_MAX_COMPAT_CONTENT_LENGTH, 'UTF-8');+ }} elseif ($mode === 'freshrss') {$item['guid'] = $this->guid();unset($item['summary']);