Skip to content

Commit 0f84bae

Browse files
committed
Fix #87: do not process hrefs pointing outside iFixit
1 parent 996489a commit 0f84bae

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.3
2+
3+
- Do not process unrecognized href, i.e. pointing outside iFixit
4+
15
# 0.2.2
26

37
- Fixed URL normalization on articles redirecting outside domain (help.ifixit.com)

ifixit2zim/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.1
1+
0.2.3

ifixit2zim/shared.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,6 @@ def _process_external_url(url, rel_prefix):
241241

242242
@staticmethod
243243
def _process_unrecognized_href(url, rel_prefix):
244-
if not url.startswith("https://") and not url.startswith("http://"):
245-
return Global._process_external_url(url, rel_prefix)
246-
try:
247-
resp = requests.head(url, timeout=5)
248-
headers = resp.headers
249-
except requests.exceptions.ConnectionError:
250-
logger.debug(f"Unable to HEAD unrecognized href (ConnectionError): {url}")
251-
return Global._process_external_url(url, rel_prefix)
252-
except requests.exceptions.ReadTimeout:
253-
logger.debug(f"Unable to HEAD unrecognized href (ReadTimeout): {url}")
254-
return Global._process_external_url(url, rel_prefix)
255-
except Exception as exc:
256-
logger.warning(f"Unable to HEAD unrecognized href: {url}")
257-
logger.exception(exc)
258-
return Global._process_external_url(url, rel_prefix)
259-
260-
contentType = headers.get("Content-Type")
261-
if contentType and contentType.startswith("image/"):
262-
return f"{rel_prefix}{Global.get_image_path(url)}"
263-
264244
return Global._process_external_url(url, rel_prefix)
265245

266246
def _process_href_regex_dynamics(href, rel_prefix):

0 commit comments

Comments
 (0)