Compare commits
3 Commits
master
...
fix-umlaun
Author | SHA1 | Date |
---|---|---|
Sebastian Lohff | 7cb85a97e7 | |
Sebastian Lohff | 0b6284cec1 | |
Sebastian Lohff | 3249647c0b |
|
@ -0,0 +1,25 @@
|
||||||
|
name: Run Tox
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python: [2.7, 3.6, 3.7, 3.8, 3.9]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
- name: Install Tox
|
||||||
|
run: pip install tox
|
||||||
|
- name: Run Tox
|
||||||
|
run: tox -e py
|
|
@ -11,6 +11,9 @@ Unreleased
|
||||||
wished the ports can be set from outside by specifying the
|
wished the ports can be set from outside by specifying the
|
||||||
environment variables SERVEFILE_DEFAULT_PORT and
|
environment variables SERVEFILE_DEFAULT_PORT and
|
||||||
SERVEFILE_SECONDARY_PORT
|
SERVEFILE_SECONDARY_PORT
|
||||||
|
* fixed broken redirect when filename contained umlauts or other characters
|
||||||
|
that should have been quoted
|
||||||
|
* drop python3.5 support
|
||||||
|
|
||||||
|
|
||||||
2020-10-30 v0.5.1
|
2020-10-30 v0.5.1
|
||||||
|
|
|
@ -60,7 +60,7 @@ class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
fileName = self.fileName
|
fileName = self.fileName
|
||||||
if unquote(self.path) != "/" + fileName:
|
if unquote(self.path) != "/" + fileName:
|
||||||
self.send_response(302)
|
self.send_response(302)
|
||||||
self.send_header('Location', '/' + fileName)
|
self.send_header('Location', '/' + quote(fileName))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -38,10 +38,10 @@ setup(
|
||||||
'Programming Language :: Python :: 2',
|
'Programming Language :: Python :: 2',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Python :: 3.5',
|
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
'Programming Language :: Python :: 3.7',
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: 3.8',
|
'Programming Language :: Python :: 3.8',
|
||||||
|
'Programming Language :: Python :: 3.9',
|
||||||
'Topic :: Communications',
|
'Topic :: Communications',
|
||||||
'Topic :: Communications :: File Sharing',
|
'Topic :: Communications :: File Sharing',
|
||||||
'Topic :: Internet',
|
'Topic :: Internet',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -14,9 +15,11 @@ import urllib3
|
||||||
|
|
||||||
if sys.version_info.major >= 3:
|
if sys.version_info.major >= 3:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from urllib.parse import quote
|
||||||
connrefused_exc = ConnectionRefusedError
|
connrefused_exc = ConnectionRefusedError
|
||||||
else:
|
else:
|
||||||
from pathlib2 import Path
|
from pathlib2 import Path
|
||||||
|
from urllib import quote
|
||||||
connrefused_exc = socket.error
|
connrefused_exc = socket.error
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,6 +165,21 @@ def test_redirect_and_download(run_servefile, datadir):
|
||||||
check_download(data, fname='testfile')
|
check_download(data, fname='testfile')
|
||||||
|
|
||||||
|
|
||||||
|
def test_redirect_and_download_with_umlaut(run_servefile, datadir):
|
||||||
|
data = "NÖÖT NÖÖT"
|
||||||
|
filename = "tästføile"
|
||||||
|
p = datadir({filename: data}) / filename
|
||||||
|
run_servefile(str(p))
|
||||||
|
|
||||||
|
# redirect
|
||||||
|
r = make_request(allow_redirects=False)
|
||||||
|
assert r.status_code == 302
|
||||||
|
assert r.headers.get('Location') == '/{}'.format(quote(filename))
|
||||||
|
|
||||||
|
# normal download
|
||||||
|
check_download(data, fname=filename)
|
||||||
|
|
||||||
|
|
||||||
def test_specify_port(run_servefile, datadir):
|
def test_specify_port(run_servefile, datadir):
|
||||||
data = "NOOT NOOT"
|
data = "NOOT NOOT"
|
||||||
p = datadir({'testfile': data}) / 'testfile'
|
p = datadir({'testfile': data}) / 'testfile'
|
||||||
|
@ -210,6 +228,7 @@ def test_serve_directory(run_servefile, datadir):
|
||||||
'bar': {'thisisaverylongfilenamefortestingthatthisstillworksproperly': 'jup!'},
|
'bar': {'thisisaverylongfilenamefortestingthatthisstillworksproperly': 'jup!'},
|
||||||
'noot': 'still data in here',
|
'noot': 'still data in here',
|
||||||
'bigfile': 'x' * (10 * 1024 ** 2),
|
'bigfile': 'x' * (10 * 1024 ** 2),
|
||||||
|
'möwe': 'KRAKRAKRAKA',
|
||||||
}
|
}
|
||||||
p = datadir(d)
|
p = datadir(d)
|
||||||
run_servefile([str(p), '-l'])
|
run_servefile([str(p), '-l'])
|
||||||
|
@ -219,7 +238,7 @@ def test_serve_directory(run_servefile, datadir):
|
||||||
for path in '/', '/../':
|
for path in '/', '/../':
|
||||||
r = make_request(path)
|
r = make_request(path)
|
||||||
for k in d:
|
for k in d:
|
||||||
assert k in r.text
|
assert quote(k) in r.text
|
||||||
|
|
||||||
for fname, content in d['foo'].items():
|
for fname, content in d['foo'].items():
|
||||||
check_download(content, '/foo/' + fname)
|
check_download(content, '/foo/' + fname)
|
||||||
|
|
Loading…
Reference in New Issue