diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 11:38:12 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 11:38:12 +0000 |
commit | a5a0ab36f31f06c69ef17240caaf3f899b161be7 (patch) | |
tree | 26992f5c35f422012f199f81958c1ba4444d2694 /base | |
parent | aa5f888a50689569f458c096fa63dba7a9d24a97 (diff) | |
download | chromium_src-a5a0ab36f31f06c69ef17240caaf3f899b161be7.zip chromium_src-a5a0ab36f31f06c69ef17240caaf3f899b161be7.tar.gz chromium_src-a5a0ab36f31f06c69ef17240caaf3f899b161be7.tar.bz2 |
Use the IAttachmentExecute service to set the Zone.Identifier stream,
when available. This is used to mark files as untrusted, because they were downloaded from the internet.
The DownloadTest.CheckInternetZone browser test was failing previously because
the Zone.Identifier stream created by the IAttachmentExecute service uses \r\n
for newlines, and the test was checking for \n.
See also http://codereview.chromium.org/590001, which this should close.
BUG=5719
TEST=DownloadTest.CheckInternetZone
Review URL: http://codereview.chromium.org/6880236
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/test/test_file_util_win.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 0159d2e..cec2f51 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -12,6 +12,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" +#include "base/string_split.h" #include "base/win/scoped_handle.h" #include "base/threading/platform_thread.h" @@ -202,19 +203,21 @@ bool HasInternetZoneIdentifier(const FilePath& full_path) { if (!file_util::ReadFileToString(zone_path, &zone_path_contents)) return false; - static const char kInternetIdentifier[] = "[ZoneTransfer]\nZoneId=3"; - static const size_t kInternetIdentifierSize = - // Don't include null byte in size of identifier. - arraysize(kInternetIdentifier) - 1; - - // Our test is that the initial characters match the above, and that - // the character after the end of the string is eof, null, or newline; any - // of those three will invoke the Window Finder cautionary dialog. - return ((zone_path_contents.compare(0, kInternetIdentifierSize, - kInternetIdentifier) == 0) && - (kInternetIdentifierSize == zone_path_contents.length() || - zone_path_contents[kInternetIdentifierSize] == '\0' || - zone_path_contents[kInternetIdentifierSize] == '\n')); + std::vector<std::string> lines; + // This call also trims whitespaces, including carriage-returns (\r). + base::SplitString(zone_path_contents, '\n', &lines); + + switch (lines.size()) { + case 3: + // optional empty line at end of file: + if (lines[2] != "") + return false; + // fall through: + case 2: + return lines[0] == "[ZoneTransfer]" && lines[1] == "ZoneId=3"; + default: + return false; + } } std::wstring FilePathAsWString(const FilePath& path) { |