Skip to content

Commit b459c94

Browse files
committed
Normalize paths before converting to url
This commit ensures to resolve any intermediate `/../` etc. and normalize case of local file paths before converting to an URL, so something like C:\\\\www\\host\.\..\file.json becomes: file:///c:/www/file.json
1 parent 6cb331e commit b459c94

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

package_control/commands/add_channel_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sublime
44
import sublime_plugin
55

6-
from os.path import isabs
6+
from os.path import isabs, normcase, normpath
77
from urllib.request import pathname2url
88

99
from ..console_write import console_write
@@ -45,7 +45,7 @@ def run(self, url=None, unattended=False):
4545
)
4646
return
4747

48-
url = "file:" + pathname2url(url)
48+
url = "file:" + pathname2url(normcase(normpath(url)))
4949

5050
settings = sublime.load_settings(pc_settings_filename())
5151
channels = settings.get('channels')

package_control/commands/add_repository_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sublime
44
import sublime_plugin
55

6-
from os.path import isabs
6+
from os.path import isabs, normcase, normpath
77
from urllib.request import pathname2url
88

99
from ..console_write import console_write
@@ -45,7 +45,7 @@ def run(self, url=None, unattended=False):
4545
)
4646
return
4747

48-
url = "file:" + pathname2url(url)
48+
url = "file:" + pathname2url(normcase(normpath(url)))
4949

5050
settings = sublime.load_settings(pc_settings_filename())
5151
repositories = settings.get('repositories')

0 commit comments

Comments
 (0)