[XenForoBridge] Fix error if message is < 70 chars (#2707)

At the time of writing, this occurs on the following thread:
https://forum.xda-developers.com/t/optimized-lineageos19-1-v4-0-23apr.4426575/

Fixes the following error:
ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) in ./rss-bridge/bridges/XenForoBridge.php:272
Stack trace:
0 ./rss-bridge/bridges/XenForoBridge.php(272): strpos()
1 ./rss-bridge/bridges/XenForoBridge.php(146): XenForoBridge->extractThreadPostsV2()
2 ./rss-bridge/actions/DisplayAction.php(134): XenForoBridge->collectData()
3 ./rss-bridge/index.php(24): DisplayAction->execute()
4 {main}
This commit is contained in:
Mynacol 2022-05-08 16:25:01 +02:00 committed by GitHub
parent d107592094
commit 36d11fd06e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -269,7 +269,7 @@ class XenForoBridge extends BridgeAbstract {
$item['uri'] = $url . '#' . $post->getAttribute('id'); $item['uri'] = $url . '#' . $post->getAttribute('id');
$title = $post->find('div[class~="message-content"] article', 0)->plaintext; $title = $post->find('div[class~="message-content"] article', 0)->plaintext;
$end = strpos($title, ' ', 70); $end = strpos($title, ' ', min(70, strlen($title)));
$item['title'] = substr($title, 0, $end); $item['title'] = substr($title, 0, $end);
if ($post->find('time[datetime]', 0)) { if ($post->find('time[datetime]', 0)) {