fix(rss): bypass WAF bot blocking with browser User-Agent and fix search feed hang - #1322
Open
heberjeur wants to merge 1 commit into
Open
fix(rss): bypass WAF bot blocking with browser User-Agent and fix search feed hang#1322heberjeur wants to merge 1 commit into
heberjeur wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
Fixes #1164
Related to #13
When subscribing to feeds protected by Cloudflare WAF / Bot Fight Mode (such as
https://www.phoronix.com/rss.php), the request was blocked with HTTP 403 Forbidden and a Cloudflare HTML challenge page, throwing:Invalid XML: Error on line 1: At line 1, column 766: not well-formed (invalid token)Additionally:
BridgeInterceptorwas injecting its defaultUser-Agent: okhttp/..., which was not replaced when checkingheader("User-Agent") == null.BestIconFinderwas downloading up to 15 icon candidate variants sequentially in cleartexthttp://, causing the subscribe search dialog to hang in the "Searching..." state for 30+ seconds.AbstractRssRepository.kt,searchedFeed.title.decodeHTML()!!had a potential NPE risk.SubscribeViewModel.kt,searchFeedaborted ifgroupsFlowwas initially empty.Fixes Applied
OkHttpClientModule.kt): Set standard Android browserUser-Agent(Mozilla/5.0 ...) at both application and network interceptor levels, filtering out OkHttp's internal default User-Agent.BestIconFinder.kt): Default tohttps://, limit icon probing to a max of 4 candidates, and wrap all icon fetching inrunCatchingso icon resolution never blocks or fails feed addition.RssHelper.kt): Checkresponse.commonIsSuccessfulbefore attempting to parse bodies as XML, logging clear HTTP error codes rather than passing HTML error pages into ROME'sXmlReader.AbstractRssRepository.kt&SubscribeViewModel.kt): Safe fallback for feed title decoding and empty group handling.OkHttpClientModuleTestandRssHelperTest.Tested
https://www.phoronix.com/rss.php) and website URL (https://www.phoronix.com)../gradlew testGithubReleaseUnitTest-> All passed../gradlew assembleGithubRelease->BUILD SUCCESSFUL.