Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: chrome/browser/policy/policy_path_parser_posix.cc

Issue 6966032: Sanitize enclosing quotes around paths in policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed one forgotten copyright header. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_path_parser_posix.cc
diff --git a/chrome/browser/policy/policy_path_parser_posix.cc b/chrome/browser/policy/policy_path_parser_posix.cc
index 6b9df82305114fc2d4bb532f88a28d3ea9162da5..2f9ea26b5df1e0c952da2570c43ad81bcc47ba7e 100644
--- a/chrome/browser/policy/policy_path_parser_posix.cc
+++ b/chrome/browser/policy/policy_path_parser_posix.cc
@@ -20,6 +20,15 @@ const char* kUserNamePolicyVarName = "${user_name}";
FilePath::StringType ExpandPathVariables(
const FilePath::StringType& untranslated_string) {
FilePath::StringType result(untranslated_string);
+ if (result.length() == 0)
+ return result;
+ // Sanitize quotes in case of any around the whole string.
+ if (result.length() > 1 &&
+ ((result[0] == '"' && result[result.length() - 1] == '"') ||
+ (result[0] == '\'' && result[result.length() - 1] == '\''))) {
+ // Strip first and last char which should be matching quotes now.
+ result = result.substr(1, result.length() - 2);
+ }
// Translate two special variables ${user_name} and ${machine_name}
size_t position = result.find(kUserNamePolicyVarName);
if (position != std::string::npos) {
« no previous file with comments | « chrome/browser/policy/policy_path_parser_mac.mm ('k') | chrome/browser/policy/policy_path_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698