OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/clipboard_util.h" | 5 #include "base/clipboard_util.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlwapi.h> | 8 #include <shlwapi.h> |
9 #include <wininet.h> | 9 #include <wininet.h> |
10 | 10 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 std::string* html, | 459 std::string* html, |
460 std::string* base_url) { | 460 std::string* base_url) { |
461 // Obtain base_url if present. | 461 // Obtain base_url if present. |
462 static std::string src_url_str("SourceURL:"); | 462 static std::string src_url_str("SourceURL:"); |
463 size_t line_start = cf_html.find(src_url_str); | 463 size_t line_start = cf_html.find(src_url_str); |
464 if (line_start != std::string::npos) { | 464 if (line_start != std::string::npos) { |
465 size_t src_end = cf_html.find("\n", line_start); | 465 size_t src_end = cf_html.find("\n", line_start); |
466 size_t src_start = line_start + src_url_str.length(); | 466 size_t src_start = line_start + src_url_str.length(); |
467 if (src_end != std::string::npos && src_start != std::string::npos) { | 467 if (src_end != std::string::npos && src_start != std::string::npos) { |
468 *base_url = cf_html.substr(src_start, src_end - src_start); | 468 *base_url = cf_html.substr(src_start, src_end - src_start); |
469 TrimWhitespace(*base_url, TRIM_ALL, base_url); | |
469 } | 470 } |
470 } | 471 } |
471 | 472 |
472 // Find the markup between "<!--StartFragment -->" and "<!--EndFragment-->". | 473 // Find the markup between "<!--StartFragment -->" and "<!--EndFragment-->". |
473 std::string cf_html_lower = StringToLowerASCII(cf_html); | 474 std::string cf_html_lower = StringToLowerASCII(cf_html); |
474 size_t markup_start = cf_html_lower.find("<html", 0); | 475 size_t markup_start = cf_html_lower.find("<html", 0); |
Evan Stade
2008/11/19 02:39:33
The function we had previously (which looks like i
| |
475 size_t tag_start = cf_html.find("StartFragment", markup_start); | 476 size_t tag_start = cf_html.find("StartFragment", markup_start); |
476 size_t fragment_start = cf_html.find('>', tag_start) + 1; | 477 size_t fragment_start = cf_html.find('>', tag_start) + 1; |
477 size_t tag_end = cf_html.find("EndFragment", fragment_start); | 478 size_t tag_end = cf_html.rfind("EndFragment", std::string::npos); |
478 size_t fragment_end = cf_html.rfind('<', tag_end); | 479 size_t fragment_end = cf_html.rfind('<', tag_end); |
479 if (fragment_start != std::string::npos && | 480 if (fragment_start != std::string::npos && |
480 fragment_end != std::string::npos) { | 481 fragment_end != std::string::npos) { |
481 *html = cf_html.substr(fragment_start, fragment_end - fragment_start); | 482 *html = cf_html.substr(fragment_start, fragment_end - fragment_start); |
482 TrimWhitespace(*html, TRIM_ALL, html); | 483 TrimWhitespace(*html, TRIM_ALL, html); |
483 } | 484 } |
484 } | 485 } |
OLD | NEW |