Skip to content

Commit

Permalink
Merge pull request #1705 from getnikola/flog-the-donkey
Browse files Browse the repository at this point in the history
Fix #1695
  • Loading branch information
ralsina committed May 8, 2015
2 parents 47cc127 + a4e11e5 commit fcf1e15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,7 @@ Features
Bugfixes
--------

* Handle strange URLs, like ed2k:// (Issue #1695)
* Fix very old metadata format support (Issue #1689)

New in v7.4.0
Expand Down
8 changes: 5 additions & 3 deletions nikola/nikola.py
Expand Up @@ -992,12 +992,16 @@ def url_replacer(self, src, dst, lang=None, url_type=None):
if url_type is None:
url_type = self.config.get('URL_TYPE')

if dst_url.scheme and dst_url.scheme not in ['http', 'https', 'link']:
return dst

# Refuse to replace links that are full URLs.
if dst_url.netloc:
if dst_url.scheme == 'link': # Magic link
dst = self.link(dst_url.netloc, dst_url.path.lstrip('/'), lang)
# Assuming the site is served over one of these, and
# since those are the only URLs we want to rewrite...
else:
print(dst)
if '%' in dst_url.netloc:
# convert lxml percent-encoded garbage to punycode
nl = unquote(dst_url.netloc)
Expand All @@ -1006,15 +1010,13 @@ def url_replacer(self, src, dst, lang=None, url_type=None):
except AttributeError:
# python 3: already unicode
pass

nl = nl.encode('idna')

dst = urlunsplit((dst_url.scheme,
nl,
dst_url.path,
dst_url.query,
dst_url.fragment))
print(dst)
return dst
elif dst_url.scheme == 'link': # Magic absolute path link:
dst = dst_url.path
Expand Down

0 comments on commit fcf1e15

Please sign in to comment.