Merge pull request #11796 from electron/case-insensitive-blacklist
Case insensitive blacklist
This commit is contained in:
commit
714838d65e
1 changed files with 21 additions and 28 deletions
|
@ -38,24 +38,20 @@ bool IsUrlArg(const base::CommandLine::CharType* arg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The blacklist of command line switches, must be sorted.
|
/*
|
||||||
// Created with:
|
* The blacklist of command line switches, must be sorted.
|
||||||
// find ./ -name "*switches.cc" \
|
* Update the list by pasting the following command into bash
|
||||||
// | xargs grep -P --no-filename "\"\S+\";" \
|
* in libchromiumcontent/src/:
|
||||||
// | perl -pe 's|^.*?"(\S+)";| "$1",|' \
|
|
||||||
// | sort | uniq
|
(find ./ -name "*switches.cc" | \
|
||||||
// then manually insert following switches into the list:
|
xargs grep -P --no-filename "\"\S+\";" | \
|
||||||
// "inspect",
|
perl -pe 's|^.*?"(\S+)";| "$1",|'; \
|
||||||
// "inspect-brk",
|
echo ' "inspect",'; \
|
||||||
// finally write a small piece of code to print out the sorted list since
|
echo ' "inspect-brk",') | \
|
||||||
// the "sort" tool may use differnt rules from C++ STL.
|
LANG=C sort | \
|
||||||
// std::vector<std::string> sorted(std::begin(kBlacklist),
|
uniq > blacklist-switches.txt
|
||||||
// std::end(kBlacklist));
|
|
||||||
// std::sort(sorted.begin(), sorted.end());
|
*/
|
||||||
// FILE* f = fopen("testlist2", "w+");
|
|
||||||
// for (auto& i : sorted)
|
|
||||||
// fprintf(f, "\"%s\",\n", i.c_str());
|
|
||||||
// fclose(f);
|
|
||||||
const char* kBlacklist[] = {
|
const char* kBlacklist[] = {
|
||||||
"/prefetch:1",
|
"/prefetch:1",
|
||||||
"/prefetch:2",
|
"/prefetch:2",
|
||||||
|
@ -1390,12 +1386,10 @@ bool IsBlacklistedArg(const base::CommandLine::CharType* arg) {
|
||||||
|
|
||||||
if (prefix_length > 0) {
|
if (prefix_length > 0) {
|
||||||
a += prefix_length;
|
a += prefix_length;
|
||||||
std::string switch_name(a, strcspn(a, "="));
|
std::string switch_name =
|
||||||
auto* iter = std::lower_bound(std::begin(kBlacklist), std::end(kBlacklist),
|
base::ToLowerASCII(base::StringPiece(a, strcspn(a, "=")));
|
||||||
switch_name);
|
return std::binary_search(std::begin(kBlacklist), std::end(kBlacklist),
|
||||||
if (iter != std::end(kBlacklist) && switch_name == *iter) {
|
switch_name);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1411,10 +1405,9 @@ bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv) {
|
||||||
return base::StringPiece(a) < base::StringPiece(b);
|
return base::StringPiece(a) < base::StringPiece(b);
|
||||||
}))
|
}))
|
||||||
<< "The kBlacklist must be in sorted order";
|
<< "The kBlacklist must be in sorted order";
|
||||||
DCHECK_NE(std::find(std::begin(kBlacklist), std::end(kBlacklist),
|
DCHECK(std::binary_search(std::begin(kBlacklist), std::end(kBlacklist),
|
||||||
base::StringPiece("inspect")),
|
base::StringPiece("inspect")))
|
||||||
std::end(kBlacklist))
|
<< "Remember to add Node command line flags to kBlacklist";
|
||||||
<< "Do not forget to add Node command line flags to kBlacklist";
|
|
||||||
|
|
||||||
const base::CommandLine::StringType dashdash(2, '-');
|
const base::CommandLine::StringType dashdash(2, '-');
|
||||||
bool block_blacklisted_args = false;
|
bool block_blacklisted_args = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue