diff --git a/Orange/data/io.py b/Orange/data/io.py index 8510678ddcf..1a952bcd0cf 100644 --- a/Orange/data/io.py +++ b/Orange/data/io.py @@ -13,7 +13,8 @@ from os import path, remove from tempfile import NamedTemporaryFile -from urllib.parse import urlparse, urlsplit, urlunsplit, unquote as urlunquote +from urllib.parse import urlparse, urlsplit, urlunsplit, \ + unquote as urlunquote, quote from urllib.request import urlopen, Request from pathlib import Path @@ -405,6 +406,7 @@ def __init__(self, filename): filename = filename.strip() if not urlparse(filename).scheme: filename = 'http://' + filename + filename = quote(filename, safe="/:") super().__init__(filename) @staticmethod diff --git a/Orange/tests/test_url_reader.py b/Orange/tests/test_url_reader.py index 87b3c1d73aa..c40bf26a2b5 100644 --- a/Orange/tests/test_url_reader.py +++ b/Orange/tests/test_url_reader.py @@ -17,3 +17,14 @@ def test_zipped(self): "http://datasets.biolab.si/core/philadelphia-crime.csv.xz" ).read() self.assertEqual(9666, len(data)) + + def test_special_characters(self): + # TO-DO - replace this file with a more appropriate one (e.g. .csv) + # and change the assertion accordingly + path = "http://file.biolab.si/text-semantics/data/elektrotehniski-" \ + "vestnik-clanki/detektiranje-utrdb-v-šahu-.txt" + self.assertRaises(OSError, UrlReader(path).read) + + +if __name__ == "__main__": + unittest.main()