mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-30 15:44:47 +02:00
fix(FeedExpander): if parse fails, include offending url in exception message (#3938)
Also some refactors
This commit is contained in:
parent
b2c8475b2c
commit
d01c462ad5
5 changed files with 56 additions and 41 deletions
|
@ -23,14 +23,20 @@ abstract class FeedExpander extends BridgeAbstract
|
|||
throw new \Exception(sprintf('Unable to parse xml from `%s` because we got the empty string', $url), 10);
|
||||
}
|
||||
// prepare/massage the xml to make it more acceptable
|
||||
$badStrings = [
|
||||
$problematicStrings = [
|
||||
' ',
|
||||
'»',
|
||||
'’',
|
||||
];
|
||||
$xmlString = str_replace($badStrings, '', $xmlString);
|
||||
$xmlString = str_replace($problematicStrings, '', $xmlString);
|
||||
|
||||
$feedParser = new FeedParser();
|
||||
$this->feed = $feedParser->parseFeed($xmlString);
|
||||
try {
|
||||
$this->feed = $feedParser->parseFeed($xmlString);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(sprintf('Failed to parse xml from %s: %s', $url, create_sane_exception_message($e)));
|
||||
}
|
||||
|
||||
$items = array_slice($this->feed['items'], 0, $maxItems);
|
||||
// todo: extract parse logic out from FeedParser
|
||||
foreach ($items as $item) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue