From 87ccc0f6672d3648b6dcb3d66b8b206242e69723 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2016 18:28:41 +0530 Subject: [PATCH] News download: Make all relative links (those starting with /) absolute --- src/calibre/web/fetch/simple.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index f91a3f637e..d796ba0611 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -523,6 +523,9 @@ class RecursiveFetcher(object): self.process_return_links(soup, newbaseurl) self.log.debug('Recursion limit reached. Skipping links in', iurl) + if newbaseurl and not newbaseurl.startswith('/'): + for atag in soup.findAll('a', href=lambda x: x and x.startswith('/')): + atag['href'] = urlparse.urljoin(newbaseurl, atag['href'], True) if callable(self.postprocess_html_ext): soup = self.postprocess_html_ext(soup, c==0 and recursion_level==0 and not getattr(self, 'called_first', False),