Skip to content

Commit

Permalink
Recognize major.minor-build as OS version number too
Browse files Browse the repository at this point in the history
As follow-up to da4e7e2, understand major.minor-build syntax in
<sparkle:minimumSystemVersion> in addition to major.minor.build.

This is a forward compatiblity measure: by using this syntax, the feed
will remain compatible with versions prior to v0.8.2. The old version
will fail to scan a string using '-' and will only see major.minor
component - and so won't misinterpret the buildnumber as service pack
version.

Should only be used if compatibility with pre-0.8.2 WinSparkle is
a concern.
  • Loading branch information
vslavik committed Dec 6, 2024
1 parent 00c189b commit 642814f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/appcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,25 @@ bool is_compatible_with_windows_version(Appcast item)
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);

const int parsed = sscanf(version.c_str(), "%lu.%lu.%lu",
&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber);
// parse the version number as major[.minor[.build]]:
int parsed = sscanf(version.c_str(), "%lu.%lu.%lu",
&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber);
if (parsed == 0)
{
// failed to parse version number, ignore the value
return true;
}

// allow alternative format major.minor-build for compatibility with
// WinSparkle < 0.8.2, which only understood major.minor.servicepack. By using '-'
// for the build component, older versions will only parse the major.minor part,
// while newer WinSparkle versions will understand the full triplet:
if (parsed == 2 && version.find('-') != std::string::npos)
{
parsed = sscanf(version.c_str(), "%lu.%lu-%lu",
&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber);
}

// backwards compatibility with WinSparkle < 0.8.2 which used major.minor.sp
// instead of major.minor.build for the version number:
if (parsed == 3 && osvi.dwBuildNumber < 100)
Expand Down

0 comments on commit 642814f

Please sign in to comment.