mirror of
https://github.com/zotero/zotero.git
synced 2026-09-07 08:26:14 +00:00
179 lines
7.2 KiB
Diff
179 lines
7.2 KiB
Diff
diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp
|
|
index 4c5982c056fd..1ad4c9dfd597 100644
|
|
--- a/browser/app/nsBrowserApp.cpp
|
|
+++ b/browser/app/nsBrowserApp.cpp
|
|
@@ -198,9 +198,20 @@ static bool HasFlag(int argc, char* argv[], const char* s) {
|
|
constinit Bootstrap::UniquePtr gBootstrap;
|
|
|
|
static int do_main(int argc, char* argv[], char* envp[]) {
|
|
+ // Allow profile downgrade for Zotero
|
|
+ _putenv_s("MOZ_ALLOW_DOWNGRADE", "1");
|
|
+ // Don't create dedicated profile (default-esr)
|
|
+ _putenv_s("MOZ_LEGACY_PROFILES", "1");
|
|
+
|
|
// Allow firefox.exe to launch XULRunner apps via -app <application.ini>
|
|
// Note that -app must be the *first* argument.
|
|
- const char* appDataFile = getenv("XUL_APP_FILE");
|
|
+ UniqueFreePtr<char> iniPath = BinaryPath::GetApplicationIni();
|
|
+ if (!iniPath) {
|
|
+ Output("Couldn't find application.ini.\n");
|
|
+ return 255;
|
|
+
|
|
+ }
|
|
+ char *appDataFile = iniPath.get();
|
|
if ((!appDataFile || !*appDataFile) && (argc > 1 && IsFlag(argv[1], "app"))) {
|
|
if (argc == 2) {
|
|
Output("Incorrect number of arguments passed to -app");
|
|
diff --git a/browser/app/winlauncher/LauncherProcessWin.cpp b/browser/app/winlauncher/LauncherProcessWin.cpp
|
|
index 8337336dc894..c55677631c88 100644
|
|
--- a/browser/app/winlauncher/LauncherProcessWin.cpp
|
|
+++ b/browser/app/winlauncher/LauncherProcessWin.cpp
|
|
@@ -250,7 +250,21 @@ static mozilla::LauncherFlags ProcessCmdLine(int& aArgc, wchar_t* aArgv[]) {
|
|
result |= mozilla::LauncherFlags::eWaitForBrowser;
|
|
}
|
|
|
|
- if (mozilla::CheckArg(aArgc, aArgv, "no-deelevate") == mozilla::ARG_FOUND) {
|
|
+ // Disable deelevation for Zotero
|
|
+ //
|
|
+ // If people are running as Administrator, or in some cases running with
|
|
+ // UAC disabled, Word runs at integrity level High and deelevation drops
|
|
+ // Zotero down to Medium, which causes 'Could not find a running Word
|
|
+ // instance' errors.
|
|
+ //
|
|
+ // Even when not running as administrator, the process switch involved in
|
|
+ // deelevation also seems to be causing various security software, such as
|
|
+ // Cisco Secure Endpoint, to block Zotero from running:
|
|
+ // https://forums.zotero.org/discussion/116762
|
|
+ //
|
|
+ // Disabling deelevation returns us to the behavior of Zotero 6, Word, and
|
|
+ // most other programs
|
|
+ if (true || mozilla::CheckArg(aArgc, aArgv, "no-deelevate") == mozilla::ARG_FOUND) {
|
|
result |= mozilla::LauncherFlags::eNoDeelevate;
|
|
}
|
|
|
|
diff --git a/toolkit/components/remote/WinRemoteMessage.cpp b/toolkit/components/remote/WinRemoteMessage.cpp
|
|
index 16a59fa7beda..4aa85c4a7632 100644
|
|
--- a/toolkit/components/remote/WinRemoteMessage.cpp
|
|
+++ b/toolkit/components/remote/WinRemoteMessage.cpp
|
|
@@ -32,6 +32,31 @@ WinRemoteMessageSender::WinRemoteMessageSender(int32_t aArgc,
|
|
|
|
COPYDATASTRUCT* WinRemoteMessageSender::CopyData() { return &mData; }
|
|
|
|
+nsresult WinRemoteMessageReceiver::ParseV0(const nsACString& aBuffer) {
|
|
+ CommandLineParserWin<char> parser;
|
|
+ parser.HandleCommandLine(aBuffer);
|
|
+
|
|
+ mCommandLine = new nsCommandLine();
|
|
+ return mCommandLine->Init(parser.Argc(), parser.Argv(), nullptr,
|
|
+ nsICommandLine::STATE_REMOTE_AUTO);
|
|
+}
|
|
+
|
|
+nsresult WinRemoteMessageReceiver::ParseV1(const nsACString& aBuffer) {
|
|
+ CommandLineParserWin<char> parser;
|
|
+ size_t cch = parser.HandleCommandLine(aBuffer);
|
|
+ ++cch; // skip a null char
|
|
+
|
|
+ nsCOMPtr<nsIFile> workingDir;
|
|
+ if (cch < aBuffer.Length()) {
|
|
+ (void)NS_NewLocalFile(NS_ConvertUTF8toUTF16(Substring(aBuffer, cch)),
|
|
+ getter_AddRefs(workingDir));
|
|
+ }
|
|
+
|
|
+ mCommandLine = new nsCommandLine();
|
|
+ return mCommandLine->Init(parser.Argc(), parser.Argv(), workingDir,
|
|
+ nsICommandLine::STATE_REMOTE_AUTO);
|
|
+}
|
|
+
|
|
nsresult WinRemoteMessageReceiver::ParseV2(const nsAString& aBuffer) {
|
|
CommandLineParserWin<char16_t> parser;
|
|
size_t cch = parser.HandleCommandLine(aBuffer);
|
|
@@ -110,6 +135,12 @@ nsresult WinRemoteMessageReceiver::ParseV3(const nsACString& aBuffer) {
|
|
|
|
nsresult WinRemoteMessageReceiver::Parse(const COPYDATASTRUCT* aMessageData) {
|
|
switch (static_cast<WinRemoteMessageVersion>(aMessageData->dwData)) {
|
|
+ case WinRemoteMessageVersion::CommandLineOnly:
|
|
+ return ParseV0(nsDependentCSubstring(
|
|
+ reinterpret_cast<char*>(aMessageData->lpData), aMessageData->cbData));
|
|
+ case WinRemoteMessageVersion::CommandLineAndWorkingDir:
|
|
+ return ParseV1(nsDependentCSubstring(
|
|
+ reinterpret_cast<char*>(aMessageData->lpData), aMessageData->cbData));
|
|
case WinRemoteMessageVersion::CommandLineAndWorkingDirInUtf16:
|
|
return ParseV2(
|
|
nsDependentSubstring(reinterpret_cast<wchar_t*>(aMessageData->lpData),
|
|
diff --git a/toolkit/components/remote/WinRemoteMessage.h b/toolkit/components/remote/WinRemoteMessage.h
|
|
index b62fb73fa13d..ee6612f55f4b 100644
|
|
--- a/toolkit/components/remote/WinRemoteMessage.h
|
|
+++ b/toolkit/components/remote/WinRemoteMessage.h
|
|
@@ -28,10 +28,10 @@
|
|
// some sort, as v3 does, to reduce the chances of variants of bug 1847458.
|
|
enum class WinRemoteMessageVersion : uint32_t {
|
|
// "<CommandLine>\0" in utf8
|
|
- /* CommandLineOnly = 0, */
|
|
+ CommandLineOnly = 0,
|
|
|
|
// "<CommandLine>\0<WorkingDir>\0" in utf8
|
|
- /* CommandLineAndWorkingDir = 1, */
|
|
+ CommandLineAndWorkingDir = 1,
|
|
|
|
// L"<CommandLine>\0<WorkingDir>\0" in utf16, used by ESR 128
|
|
CommandLineAndWorkingDirInUtf16 = 2,
|
|
@@ -61,6 +61,8 @@ class WinRemoteMessageSender final {
|
|
class WinRemoteMessageReceiver final {
|
|
nsCOMPtr<nsICommandLineRunner> mCommandLine;
|
|
|
|
+ nsresult ParseV0(const nsACString& aBuffer);
|
|
+ nsresult ParseV1(const nsACString& aBuffer);
|
|
nsresult ParseV2(const nsAString& aBuffer);
|
|
nsresult ParseV3(const nsACString& aBuffer);
|
|
|
|
diff --git a/toolkit/mozapps/update/common/commonupdatedir.cpp b/toolkit/mozapps/update/common/commonupdatedir.cpp
|
|
index 0ba9fcef9417..ed286476fec3 100644
|
|
--- a/toolkit/mozapps/update/common/commonupdatedir.cpp
|
|
+++ b/toolkit/mozapps/update/common/commonupdatedir.cpp
|
|
@@ -43,7 +43,7 @@
|
|
// this problem in the future, we are including a UUID in the root update
|
|
// directory name to attempt to ensure that it will be created by this code and
|
|
// won't already exist with the wrong permissions.
|
|
-# define ROOT_UPDATE_DIR_NAME "Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38"
|
|
+# define ROOT_UPDATE_DIR_NAME "Zotero"
|
|
// This describes the directory between the "Mozilla" directory and the install
|
|
// path hash (i.e. C:\ProgramData\Mozilla\<UPDATE_PATH_MID_DIR_NAME>\<hash>)
|
|
# define UPDATE_PATH_MID_DIR_NAME "updates"
|
|
diff --git a/xpcom/build/BinaryPath.h b/xpcom/build/BinaryPath.h
|
|
index 2c8d78f02440..f55d3db32469 100644
|
|
--- a/xpcom/build/BinaryPath.h
|
|
+++ b/xpcom/build/BinaryPath.h
|
|
@@ -286,6 +286,33 @@ class BinaryPath {
|
|
return result;
|
|
}
|
|
|
|
+ static UniqueFreePtr<char> GetApplicationIni() {
|
|
+ char path[MAXPATHLEN];
|
|
+ if (NS_FAILED(Get(path))) {
|
|
+ return nullptr;
|
|
+ }
|
|
+
|
|
+ char *c = path + strlen(path);
|
|
+ while (c >= path && *c != '\\' && *c != '/') {
|
|
+ *c = NULL;
|
|
+ c--;
|
|
+ }
|
|
+
|
|
+ if (c < path) {
|
|
+ return nullptr;
|
|
+ }
|
|
+
|
|
+ char iniPath[MAXPATHLEN];
|
|
+ int n = snprintf(iniPath, MAXPATHLEN, "%s\\app\\application.ini", path);
|
|
+ if (n < 0 || n >= MAXPATHLEN) {
|
|
+ return nullptr;
|
|
+ }
|
|
+
|
|
+ UniqueFreePtr<char> result;
|
|
+ result.reset(strdup(iniPath));
|
|
+ return result;
|
|
+ }
|
|
+
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
static nsresult GetFile(nsIFile** aResult) {
|
|
nsCOMPtr<nsIFile> lf;
|