OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 return NULL; | 828 return NULL; |
829 } | 829 } |
830 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 830 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
831 std::string filter; | 831 std::string filter; |
832 if (!list_value->GetString(i, &filter)) { | 832 if (!list_value->GetString(i, &filter)) { |
833 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 833 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
834 errors::kInvalidFileFilterValue, base::IntToString(i)); | 834 errors::kInvalidFileFilterValue, base::IntToString(i)); |
835 return NULL; | 835 return NULL; |
836 } | 836 } |
837 StringToLowerASCII(&filter); | 837 StringToLowerASCII(&filter); |
| 838 if (filter.substr(0, 10) != chrome::kFileSystemScheme || |
| 839 filter[10] != ':') { |
| 840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 841 errors::kInvalidURLPatternError, filter); |
| 842 return NULL; |
| 843 } |
| 844 filter.replace(11, 0, "chrome-extension://*/"); |
838 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); | 845 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); |
| 846 pattern.SetValidInnerSchemes(URLPattern::SCHEME_EXTENSION); |
839 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { | 847 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { |
840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 848 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
841 errors::kInvalidURLPatternError, filter); | 849 errors::kInvalidURLPatternError, filter); |
842 return NULL; | 850 return NULL; |
843 } | 851 } |
844 std::string path = pattern.path(); | 852 std::string path = pattern.path(); |
845 bool allowed = path == "*" || path == "*.*" || | 853 bool allowed = path == "/*" || path == "/*.*" || |
846 (path.compare(0, 2, "*.") == 0 && | 854 (path.compare(0, 3, "/*.") == 0 && |
847 path.find_first_of('*', 2) == std::string::npos); | 855 path.find_first_of('*', 3) == std::string::npos); |
848 if (!allowed) { | 856 if (!allowed) { |
849 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 857 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
850 errors::kInvalidURLPatternError, filter); | 858 errors::kInvalidURLPatternError, filter); |
851 return NULL; | 859 return NULL; |
852 } | 860 } |
853 result->AddPattern(pattern); | 861 result->AddPattern(pattern); |
854 } | 862 } |
855 | 863 |
856 std::string default_icon; | 864 std::string default_icon; |
857 // Read the file browser action |default_icon| (optional). | 865 // Read the file browser action |default_icon| (optional). |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 already_disabled(false), | 3088 already_disabled(false), |
3081 extension(extension) {} | 3089 extension(extension) {} |
3082 | 3090 |
3083 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3091 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3084 const Extension* extension, | 3092 const Extension* extension, |
3085 const ExtensionPermissionSet* permissions, | 3093 const ExtensionPermissionSet* permissions, |
3086 Reason reason) | 3094 Reason reason) |
3087 : reason(reason), | 3095 : reason(reason), |
3088 extension(extension), | 3096 extension(extension), |
3089 permissions(permissions) {} | 3097 permissions(permissions) {} |
OLD | NEW |