-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FeedExpander] Add prepareXml() overridable function #4485
base: master
Are you sure you want to change the base?
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 |
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.