Skip to content

Add an option to set a custom user agent to retrieve individual feeds#3494

Merged
Alkarex merged 5 commits intoFreshRSS:masterfrom
Jules-Bertholet:3493-custom-ua
Mar 9, 2021
Merged

Add an option to set a custom user agent to retrieve individual feeds#3494
Alkarex merged 5 commits intoFreshRSS:masterfrom
Jules-Bertholet:3493-custom-ua

Conversation

@Jules-Bertholet
Copy link
Contributor

@Jules-Bertholet Jules-Bertholet commented Mar 3, 2021

This allows retrieving the original RSS feed when websites use services like FeedBurner.

Closes #3493

Changes proposed in this pull request:

  • Add a setting to choose the user agent used when fetching feeds

How to test the feature manually:

  1. Add a feed that is fronted by FeedBurner to FreshRSS. One such is https://www.themoneyillusion.com/feed/atom
  2. Set the user agent to FeedBurner
  3. Ensure the feed location still points to https://www.themoneyillusion.com/feed/atom, and was not changed to the FeedBurner feed because of a 3XX redirect before you added the user-agent
  4. Re-fetch feed content
  5. All feed items should now refer to the original site, not feedproxy.google.com or similar

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

Additional information can be found in the documentation.

'ttl' => 'Do not automatically refresh more often than',
'url' => 'Feed URL',
'useragent' => 'Set the user agent for fetching this feed',
'useragent_help' => 'Example: <kbd>FeedBurner</kbd>',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use another example, avoiding specific product names, but a more general browser, e.g.

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)

@Alkarex Alkarex added this to the 1.18.0 milestone Mar 3, 2021
@Alkarex
Copy link
Member

Alkarex commented Mar 3, 2021

Please add a line for your new string in ./cli/i18n/ignore/en-us.php to ignore the fact that it is the same string in en-GB and en-US

Copy link
Member

@aledeg aledeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the translating strings from en_US in the ignore file?
Run this command to do that: make i18n-ignore-unmodified-keys lang=en-us

Edit This will fix the CI error!

if ($cookie != '') {
$opts[CURLOPT_COOKIE] = $cookie;
}
if ($useragent != '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use !== instead of !=.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the code around does not use it, but I think it should. We will fix it when working on it.

Georgelemental added 2 commits March 3, 2021 10:32
This allows retrieving the original RSS feed when websites use services like FeedBurner.
@Alkarex
Copy link
Member

Alkarex commented Mar 3, 2021

Works fine. But maybe this option should be made available from the Add feed page (?c=subscription&a=add) as well? Otherwise it might not be possible to add a feed, which requires a specific user agent. Around there https://github.com/FreshRSS/FreshRSS/blob/master/app/views/subscription/add.phtml#L62 and there https://github.com/FreshRSS/FreshRSS/blob/master/app/Controllers/subscriptionController.php#L130

Furthermore, we should either only allow those options for admins, or make them use a user-specific cache, as this might otherwise randomly affect other users of the same FreshRSS instance. See #3367 (comment) This should be in another PR though, but must be done before the release of 1.18.0.

Alkarex added a commit to Alkarex/FreshRSS that referenced this pull request Mar 6, 2021
@Alkarex
Copy link
Member

Alkarex commented Mar 7, 2021

Patch to avoid SimplePie cache pollution when changing cURL options: #3502

@Alkarex Alkarex closed this in #3502 Mar 9, 2021
Alkarex added a commit that referenced this pull request Mar 9, 2021
* SimplePie prevent cache polution
#fix #3367 (comment)
#fix #3494 (comment)

* Fix bug

* Minor improvement

* Update cache filename in FreshRSS (1/2)

* cacheFilename temp

* New SimplePie get_cache_filename()

* Fix typos

* Update lib/SimplePie/SimplePie.php

Typo

* Include user-agent and timeout

* fix array_merge

* Declaration

* force_feed was lost in a commit
@Alkarex Alkarex reopened this Mar 9, 2021
@Alkarex
Copy link
Member

Alkarex commented Mar 9, 2021

@Jules-Bertholet I have added the user-agent (and proxy) option to the subscription page to add a new feed:
f9495f5

image

Could you please give it a quick test?

@Jules-Bertholet
Copy link
Contributor Author

@Alkarex Works great! (Proxy not tested)

@Alkarex Alkarex merged commit 800a421 into FreshRSS:master Mar 9, 2021
@Alkarex
Copy link
Member

Alkarex commented Mar 9, 2021

Thanks for the quick test :-)

@Frenzie
Copy link
Member

Frenzie commented Mar 9, 2021 via email

@Alkarex
Copy link
Member

Alkarex commented Mar 9, 2021

@Jules-Bertholet Could you please add a line for you in https://github.com/FreshRSS/FreshRSS/blob/master/CREDITS.md ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Allow setting custom user-agent when retrieving particular feeds

4 participants