summaryrefslogtreecommitdiffstats
path: root/base/command_line.h
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-06 10:25:35 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-06 10:25:35 +0000
commit02c8796f86e238be73fecd15b894724d58a96f4d (patch)
tree24c98fc21034b55c54d7f907a7977d0680d10322 /base/command_line.h
parent095214d9fd4f7dc5b9218d3fe78cf3ee08f480b8 (diff)
downloadchromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.zip
chromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.tar.gz
chromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.tar.bz2
Add -- as a command line switch parsing terminator. This allows you to launch chrome to a given URL safely, without having to validate the URL and worry it might be interpreted as a dangerous command line argument.
Review URL: http://codereview.chromium.org/6480 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.h')
-rw-r--r--base/command_line.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/base/command_line.h b/base/command_line.h
index 5574790..7e54fd4 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -1,16 +1,17 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-//
+
// This file contains a class that can be used to extract the salient
// elements of a command line in a relatively lightweight manner.
// Switches can optionally have a value attached using an equals sign,
// as in "-switch=value". Arguments that aren't prefixed with a
// switch prefix are considered "loose parameters". Switch names
-// are case-insensitive.
+// are case-insensitive. An argument of "--" will terminate switch parsing,
+// causing everything after to be considered as loose parameters.
-#ifndef BASE_COMMAND_LINE_H__
-#define BASE_COMMAND_LINE_H__
+#ifndef BASE_COMMAND_LINE_H_
+#define BASE_COMMAND_LINE_H_
#include <map>
#include <string>
@@ -76,6 +77,9 @@ class CommandLine {
// The string that's used to separate switches from their values.
static const wchar_t kSwitchValueSeparator[];
+ // Treat everything after this argument as loose parameters.
+ static const wchar_t kSwitchTerminator[];
+
// Appends the given switch string (preceded by a space and a switch
// prefix) to the given string.
static void AppendSwitch(std::wstring* command_line_string,
@@ -101,5 +105,4 @@ class CommandLine {
DISALLOW_EVIL_CONSTRUCTORS(CommandLine);
};
-#endif // BASE_COMMAND_LINE_H__
-
+#endif // BASE_COMMAND_LINE_H_