[FeedExpander] Add prepareXml() overridable function#4485
[FeedExpander] Add prepareXml() overridable function#4485dvikan merged 5 commits intoRSS-Bridge:masterfrom
Conversation
- Move preprocessing code into overridable preprocessXml() - Auto-remove trailing data after root xml node
|
looks fine but hard to say whether this introduces bugs (due to the hard-to-read regex) |
|
Okay, I'll try to explain the regex https://regex101.com/r/NmetjG/1
Now, the same code without regex and error handling would look like this: With error handling (do not touch $xmlString if we are not 100% sure): Again, if none of these approaches seems satisfactory for code reliability and maintainability, that's okay, I'll remove it from |
|
i dunno man. you make the call. ill merge if you want |
|
OK. Just to be safe, I'll move this code to a separate bridge and will come back with it if I encounter one more site with this kind of feed malformation. I'll change the PR to just include the overridable |
Will add back later if more sites have the same issue
|
you can type hint both function param and function return value |
|
Done! |
* FeedExpander: Remove tailing content in XML - Move preprocessing code into overridable preprocessXml() - Auto-remove trailing data after root xml node * FeedExpander: Add PR reference with use case * FeedExpander: Code linting * [FeedExpander] Keep content at end of document for now Will add back later if more sites have the same issue * [FeedExpander] prepareXml: Add type hints

What this pull request does
FeedExpander.php
prepareXml($xmlString)function and move existing cleanup code insideAuto-remove trailing content after root xml node(removed from PR, see discussion below)Use case: remove analytic tags inserted in XML feeds
One of my bridge stopped working with the following error:
Turns out the site's feed had an extra script tag from CloudFlare:
This PR adds auto-cleaning to remove trailing data causing XML parsing to fail.This PR allows overriding
prepareXml($xmlString)from a bridge to clean XML before it gets parsed.Seems like all my bridges still load fine on my instance after the change, and this fixed my broken feed. If you think this could break things, let me know and I'll move that code in a separate bridge on my instance.