Use strcoll_l() for locale-independent comparisons (#2087)

The update code uses the compareFiles function to determine the sort order of file names in a directory, which is then compared with a list of files in the Sparkle update info. If the list of files of a directory from Sparkle's update is different than what is on disk, the Sparkle abandons the update and does a full download. This bug would prevent Sparkle from updating properly when the file lists are calculated on an English language system, but then checked on a destination Japanese system.

The fix is to use strcoll_l(), which is locale-independent, when comparing file names for sorting. This will ignore any locale changes the host application has made that could potentially affect Sparkle's sort order.
This commit is contained in:
Dan Rigdon-Bel authored and GitHub committed 2022-02-08 20:38:55 -08:00
1 parent eb938ad15a
commit 8edc77fdb2
1 file changed
+2 -1
+2 -1
View File
@@ -16,6 +16,7 @@
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <xlocale.h>
#include "AppKitPrevention.h"
@@ -89,7 +90,7 @@ NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode)
int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll((*a)->fts_name, (*b)->fts_name);
return strcoll_l((*a)->fts_name, (*b)->fts_name, _c_locale);
}
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)