Skip to content
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

elfeed-show-refresh--mail-style base URL is incorrect for kottke.org #476

Open
kamidon opened this issue Dec 5, 2022 · 3 comments
Open

Comments

@kamidon
Copy link

kamidon commented Dec 5, 2022

I subscribe to the RSS feed of kottke.org at https://feeds.kottke.org/main. However, all the article links are at https://kottke.org/. The elfeed-show-refresh--mail-style function computes the base URL that it uses to insert HTML into the elfeed-show buffer from the feed URL. As a result images in the article with relative paths fail to render because they are pulled from https://feeds.kottke.org/<image path> instead of https://kottke.org/<image path>.

I have worked around the problem by temporarily redefining that function to use the link URL instead of the feed URL. This fixes the problem for kottke.org and I haven't noticed any other problems for other feeds yet. However, I'm unsure whether there are potential issues that I haven't run into yet.

@kamidon
Copy link
Author

kamidon commented Dec 5, 2022

One potential concern that I have is that link URLs could theoretically pointing anywhere, not just at the site I originally configured. It would be nice to lock that down more tightly somehow. Perhaps having an elfeed-entry-base-url property for feeds that gets used in place of calculating the base URL from the feed URL if configured.

@kamidon
Copy link
Author

kamidon commented Jan 17, 2023

I looked at this a bit more today. I was thinking of changing elfeed-show-refresh--mail-style to check if the metadata on the feed has a :entry-base-url plist entry and use that in place of the current base computed from the feed URL if present. Would a change like this be acceptable?

I'm an elfeed-org user as well so if this change would be acceptable I'll also submit a PR to elfeed-org to allow feed metadata to be specified, probably using a property on the feed entries.

@kamidon
Copy link
Author

kamidon commented May 31, 2023

Given the proposed commit I made hasn't had an enthusiastic reception I've resorted to solving this a different way for now. I used :around advice on elfeed-compute-base that intercepts the URL being passed in, matches against it, and allows it to be replaced. If anyone arrives here and is interested in this workaround, the advice function I defined is:

 (defvar kea/elfeed-compute-base-url-rewrites nil
   "List of lists of replace-regexp-in-string arguments w/o the actual string")
 (defun kea/elfeed-compute-base-url-rewrite-advice (fn url)
   (mapc (lambda (args)
           (let ((regexp (nth 0 args))
                 (rep (nth 1 args))
                 (optargs (nthcdr 2 args)))
             (setq url (apply #'replace-regexp-in-string regexp rep url optargs))))
         kea/elfeed-compute-base-url-rewrites)
   (funcall fn url))

For the problem reporting here I'm setting kea/elfeed-compute-base-url-rewrites to

   (setq kea/elfeed-compute-base-url-rewrites
               `((,(rx line-start "http" (opt "s") "://feeds.kottke.org/")
                  "https://kottke.org/")))

I still think my proposed patch is a more elegant solution for this problem, but this works around the problem until there is an upstream fix without me having to maintain my fork.

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

No branches or pull requests

1 participant