Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' into do-1985
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Sep 1, 2015
2 parents 4edd6e0 + 4e0be1b commit e4b7806
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -28,6 +28,7 @@ Features
Bugfixes
--------

* Link checker should check all absolute URLs to self (Issue #1991)
* Check ``img|source[@srcset]`` as part of ``check -l`` (Issue #1989)
* Clean up translations for third party components
* ``pagekind["main_index"]`` set on the main indexes to differentiate
Expand Down
2 changes: 1 addition & 1 deletion nikola/nikola.py
Expand Up @@ -1106,7 +1106,7 @@ def rewrite_links(self, doc, src, lang):
doc.rewrite_links(lambda dst: self.url_replacer(src, dst, lang), resolve_base_href=False)

# lxml ignores srcset in img and source elements, so do that by hand
objs = list(doc.findall('(*//img|*//source)'))
objs = list(doc.xpath('(*//img|*//source)'))
for obj in objs:
if 'srcset' in obj.attrib:
urls = [u.strip() for u in obj.attrib['srcset'].split(',')]
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugins/command/check.py
Expand Up @@ -217,6 +217,11 @@ def analyze(self, fname, find_sources=False, check_remote=False):
if target == "#":
continue
target, _ = urldefrag(target)

# absolute URL to root-relative
if target.startswith(base_url.geturl()):
target = target.replace(base_url.geturl(), '/')

parsed = urlparse(target)

# Warn about links from https to http (mixed-security)
Expand All @@ -229,8 +234,6 @@ def analyze(self, fname, find_sources=False, check_remote=False):
((parsed.scheme or target.startswith('//')) and url_type in ('rel_path', 'full_path')):
if not check_remote or parsed.scheme not in ["http", "https"]:
continue
if parsed.netloc == base_url.netloc: # absolute URL to self.site
continue
if target in self.checked_remote_targets: # already checked this exact target
if self.checked_remote_targets[target] in [301, 307]:
self.logger.warn("Remote link PERMANENTLY redirected in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
Expand Down

0 comments on commit e4b7806

Please sign in to comment.