Merge remote-tracking branch 'origin/pr/3291'

This commit is contained in:
Florian Bruhin 2017-11-16 10:17:02 +01:00
commit b3085f5d60
4 changed files with 32 additions and 1 deletions

View File

@ -64,6 +64,7 @@ def path_up(url, count):
raise Error("Can't go up!")
for _i in range(0, min(count, path.count('/'))):
path = posixpath.join(path, posixpath.pardir)
path = posixpath.normpath(path)
url.setPath(path)
return url

View File

@ -135,6 +135,11 @@ def data_for_url(url):
Return:
A (mimetype, data) tuple.
"""
norm_url = url.adjusted(QUrl.NormalizePathSegments |
QUrl.StripTrailingSlash)
if norm_url != url:
raise Redirect(norm_url)
path = url.path()
host = url.host()
query = urlutils.query_string(url)
@ -331,9 +336,13 @@ def qute_help(url):
path = 'html/doc/{}'.format(urlpath)
if not urlpath.endswith('.html'):
try:
bdata = utils.read_file(path, binary=True)
except OSError as e:
raise QuteSchemeOSError(e)
mimetype, _encoding = mimetypes.guess_type(urlpath)
assert mimetype is not None, url
return mimetype, utils.read_file(path, binary=True)
return mimetype, bdata
try:
data = utils.read_file(path)

View File

@ -18,6 +18,11 @@ Feature: Using :navigate
And I run :navigate up with count 2
Then data/navigate should be loaded
Scenario: Navigating up in qute://help/
When I open qute://help/commands.html
And I run :navigate up
Then qute://help/ should be loaded
# prev/next
Scenario: Navigating to previous page

View File

@ -63,6 +63,22 @@ Feature: Special qute:// pages
And I hint with args "links normal" and follow a
Then qute://help/quickstart.html should be loaded
Scenario: Opening a link with qute://help/index.html/..
When the documentation is up to date
And I open qute://help/index.html/.. without waiting
Then qute://help/ should be loaded
Scenario: Opening a link with qute://help/index.html/../
When the documentation is up to date
And I open qute://help/index.html/../ without waiting
Then qute://help/ should be loaded
Scenario: Opening a link with qute://help/img/
When the documentation is up to date
And I open qute://help/img/ without waiting
Then "OSError while handling qute://* URL" should be logged
And "* url='qute://help/img'* LoadStatus.error" should be logged
# :history
Scenario: :history without arguments