Skip to content

Commit aa47563

Browse files
authored
Block Windows Server 2019 from MSIX install. (#107)
Few minor fixes for older OS. Fixes #106
1 parent 5ee86eb commit aa47563

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/_native/winhttp.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,21 @@ PyObject *winhttp_urlopen(PyObject *, PyObject *args, PyObject *kwargs) {
209209
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY,
210210
WINHTTP_NO_PROXY_NAME,
211211
WINHTTP_NO_PROXY_BYPASS,
212-
url_parts.nScheme == INTERNET_SCHEME_HTTPS ? WINHTTP_FLAG_SECURE_DEFAULTS : 0
212+
url_parts.nScheme == INTERNET_SCHEME_HTTPS
213+
? WINHTTP_FLAG_SECURE_DEFAULTS & ~WINHTTP_FLAG_ASYNC
214+
: 0
213215
);
216+
if (!hSession && GetLastError() == ERROR_INVALID_PARAMETER) {
217+
// WINHTTP_FLAG_SECURE_DEFAULTS is not supported on older OS, so we'll
218+
// retry without it.
219+
hSession = WinHttpOpen(
220+
NULL,
221+
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY,
222+
WINHTTP_NO_PROXY_NAME,
223+
WINHTTP_NO_PROXY_BYPASS,
224+
0
225+
);
226+
}
214227
CHECK_WINHTTP(hSession);
215228

216229
hConnection = WinHttpConnect(

src/manage/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def config_bool(v):
3636
return bool(v)
3737

3838

39+
def _is_valid_url(u):
40+
from .urlutils import is_valid_url
41+
return is_valid_url(u)
42+
43+
3944
def load_global_config(cfg, schema):
4045
try:
4146
from _native import package_get_root
@@ -184,7 +189,7 @@ def resolve_config(cfg, source, relative_to, key_so_far="", schema=None, error_u
184189
v = kind(v)
185190
except (TypeError, ValueError):
186191
raise InvalidConfigurationError(source, key_so_far + k, v)
187-
if v and "path" in opts:
192+
if v and "path" in opts and not _is_valid_url(v):
188193
# Paths from the config file are relative to the config file.
189194
# Paths from the environment are relative to the current working dir
190195
if not from_env:
@@ -196,8 +201,7 @@ def resolve_config(cfg, source, relative_to, key_so_far="", schema=None, error_u
196201
v = v.as_uri()
197202
else:
198203
v = str(v)
199-
from .urlutils import is_valid_url
200-
if not is_valid_url(v):
204+
if not _is_valid_url(v):
201205
raise InvalidConfigurationError(source, key_so_far + k, v)
202206
cfg[k] = v
203207

src/manage/urlutils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,10 @@ def __iter__(self):
639639

640640
def on_auth(self, url):
641641
# TODO: Try looking for parent paths from URL
642-
return self._auth[url]
642+
try:
643+
return self._auth[url]
644+
except LookupError:
645+
return None
643646

644647
def __next__(self):
645648
if not self._url:

src/pymanager/appxmanifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<Resource Language="en-US" />
3333
</Resources>
3434
<Dependencies>
35-
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.26100.0" />
35+
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19044.0" MaxVersionTested="10.0.26100.0" />
3636
</Dependencies>
3737
<Capabilities>
3838
<rescap:Capability Name="runFullTrust" />

0 commit comments

Comments
 (0)