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

Side by Side Diff: chrome/browser/net/url_fixer_upper.cc

Issue 7572046: Be a little more careful whether something is an URL or a file path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/net/url_fixer_upper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/net/url_fixer_upper.h" 5 #include "chrome/browser/net/url_fixer_upper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Save the old current directory before we move to the new one. 531 // Save the old current directory before we move to the new one.
532 file_util::GetCurrentDirectory(&old_cur_directory); 532 file_util::GetCurrentDirectory(&old_cur_directory);
533 file_util::SetCurrentDirectory(base_dir); 533 file_util::SetCurrentDirectory(base_dir);
534 } 534 }
535 535
536 // Allow funny input with extra whitespace and the wrong kind of slashes. 536 // Allow funny input with extra whitespace and the wrong kind of slashes.
537 FilePath::StringType trimmed; 537 FilePath::StringType trimmed;
538 PrepareStringForFileOps(text, &trimmed); 538 PrepareStringForFileOps(text, &trimmed);
539 539
540 bool is_file = true; 540 bool is_file = true;
541 // Avoid recognizing definite non-file URLs as file paths.
542 GURL gurl(trimmed);
543 if (gurl.is_valid() && gurl.IsStandard())
544 is_file = false;
541 FilePath full_path; 545 FilePath full_path;
542 if (!ValidPathForFile(trimmed, &full_path)) { 546 if (is_file && !ValidPathForFile(trimmed, &full_path)) {
543 // Not a path as entered, try unescaping it in case the user has 547 // Not a path as entered, try unescaping it in case the user has
544 // escaped things. We need to go through 8-bit since the escaped values 548 // escaped things. We need to go through 8-bit since the escaped values
545 // only represent 8-bit values. 549 // only represent 8-bit values.
546 #if defined(OS_WIN) 550 #if defined(OS_WIN)
547 std::wstring unescaped = UTF8ToWide(UnescapeURLComponent( 551 std::wstring unescaped = UTF8ToWide(UnescapeURLComponent(
548 WideToUTF8(trimmed), 552 WideToUTF8(trimmed),
549 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS)); 553 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS));
550 #elif defined(OS_POSIX) 554 #elif defined(OS_POSIX)
551 std::string unescaped = UnescapeURLComponent( 555 std::string unescaped = UnescapeURLComponent(
552 trimmed, 556 trimmed,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 597
594 if (part->is_valid()) { 598 if (part->is_valid()) {
595 // Offset the location of this component. 599 // Offset the location of this component.
596 part->begin += offset; 600 part->begin += offset;
597 601
598 // This part might not have existed in the original text. 602 // This part might not have existed in the original text.
599 if (part->begin < 0) 603 if (part->begin < 0)
600 part->reset(); 604 part->reset();
601 } 605 }
602 } 606 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/url_fixer_upper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698