File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,10 @@ def _get_reader(self) -> FileFormat:
470470 return reader
471471 else :
472472 url = self .url_combo .currentText ().strip ()
473+ # tolerant parse, also prevent parsing as local file
474+ parsed = QUrl .fromUserInput (url , os .devnull )
475+ if parsed .isValid ():
476+ url = bytes (parsed .toEncoded ()).decode ("ascii" )
473477 return UrlReader (url )
474478
475479 def _update_sheet_combo (self ):
Original file line number Diff line number Diff line change @@ -577,6 +577,21 @@ def test_url_no_scheme(self):
577577
578578 mock_urlreader .assert_called_once_with ('http://' + url )
579579
580+ def test_url_encode (self ):
581+ def test (text , expected ):
582+ mock_urlreader = Mock ()
583+ with patch ('Orange.widgets.data.owfile.UrlReader' , mock_urlreader ):
584+ self .widget .url_combo .insertItem (0 , text )
585+ self .widget .url_combo .setCurrentIndex (0 )
586+ self .widget .url_combo .activated .emit (0 )
587+ mock_urlreader .assert_called_once_with (expected )
588+
589+ test ("https://example.com/space space#f=f" , "https://example.com/space%20space#f=f" )
590+ test ("https://example.com/space%20space#f=f" , "https://example.com/space%20space#f=f" )
591+ test ("https://š.si/š#f=1" , "https://xn--pga.si/%C5%A1#f=1" )
592+ test ("https://xn--pga.si/%C5%A1#f=1" , "https://xn--pga.si/%C5%A1#f=1" )
593+ test ("https://example.com/a?q=1#f=1" , "https://example.com/a?q=1#f=1" )
594+
580595 def test_adds_origin (self ):
581596 self .open_dataset ("origin1/images" )
582597 data1 = self .get_output (self .widget .Outputs .data )
You can’t perform that action at this time.
0 commit comments