fix: ignore non-absolute session preload script paths when sandboxed (#19066)
This commit is contained in:
parent
50b9c7051e
commit
69ea0b4ebf
10 changed files with 46 additions and 64 deletions
|
@ -4,22 +4,8 @@
|
|||
|
||||
#include "shell/browser/session_preferences.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(';');
|
||||
#else
|
||||
const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(':');
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
int SessionPreferences::kLocatorKey = 0;
|
||||
|
||||
|
@ -36,26 +22,21 @@ SessionPreferences* SessionPreferences::FromBrowserContext(
|
|||
}
|
||||
|
||||
// static
|
||||
void SessionPreferences::AppendExtraCommandLineSwitches(
|
||||
content::BrowserContext* context,
|
||||
base::CommandLine* command_line) {
|
||||
SessionPreferences* self = FromBrowserContext(context);
|
||||
if (!self)
|
||||
return;
|
||||
std::vector<base::FilePath::StringType> SessionPreferences::GetValidPreloads(
|
||||
content::BrowserContext* context) {
|
||||
std::vector<base::FilePath::StringType> result;
|
||||
|
||||
base::FilePath::StringType preloads;
|
||||
for (const auto& preload : self->preloads()) {
|
||||
if (!base::FilePath(preload).IsAbsolute()) {
|
||||
LOG(ERROR) << "preload script must have absolute path: " << preload;
|
||||
continue;
|
||||
if (auto* self = FromBrowserContext(context)) {
|
||||
for (const auto& preload : self->preloads()) {
|
||||
if (base::FilePath(preload).IsAbsolute()) {
|
||||
result.emplace_back(preload);
|
||||
} else {
|
||||
LOG(ERROR) << "preload script must have absolute path: " << preload;
|
||||
}
|
||||
}
|
||||
if (preloads.empty())
|
||||
preloads = preload;
|
||||
else
|
||||
preloads += kPathDelimiter + preload;
|
||||
}
|
||||
if (!preloads.empty())
|
||||
command_line->AppendSwitchNative(switches::kPreloadScripts, preloads);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue