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

Side by Side Diff: content/public/common/common_param_traits.cc

Issue 11576038: Beware of print-read inconsistency when serializing GURLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | no next file » | 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) 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 "content/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include "content/public/common/content_constants.h" 7 #include "content/public/common/content_constants.h"
8 #include "content/public/common/referrer.h" 8 #include "content/public/common/referrer.h"
9 #include "net/base/host_port_pair.h" 9 #include "net/base/host_port_pair.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return true; 43 return true;
44 } 44 }
45 }; 45 };
46 46
47 } // namespace 47 } // namespace
48 48
49 namespace IPC { 49 namespace IPC {
50 50
51 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { 51 void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
52 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); 52 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars);
53
54 // Beware of print-parse inconsistency which would change an invalid
55 // URL into a valid one. Ideally, the message would contain this flag
56 // so that the read side could make the check, but performing it here
57 // avoids changing the on-the-wire representation of such a fundamental
58 // type as GURL. See https://crbug.com/166486 for additional work in
59 // this area.
60 if (!p.is_valid()) {
61 GURL reconstructed_url(p.possibly_invalid_spec());
62 if (reconstructed_url.is_valid()) {
63 DLOG(WARNING) << "GURL string " << p.possibly_invalid_spec()
64 << " (marked invalid) but parsed as valid.";
65 m->WriteString(std::string());
66 return;
67 }
68 }
69
53 m->WriteString(p.possibly_invalid_spec()); 70 m->WriteString(p.possibly_invalid_spec());
54 // TODO(brettw) bug 684583: Add encoding for query params. 71 // TODO(brettw) bug 684583: Add encoding for query params.
55 } 72 }
56 73
57 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { 74 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) {
58 std::string s; 75 std::string s;
59 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { 76 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) {
60 *p = GURL(); 77 *p = GURL();
61 return false; 78 return false;
62 } 79 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 322 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
306 #include "content/public/common/common_param_traits_macros.h" 323 #include "content/public/common/common_param_traits_macros.h"
307 } // namespace IPC 324 } // namespace IPC
308 325
309 // Generate param traits log methods. 326 // Generate param traits log methods.
310 #include "ipc/param_traits_log_macros.h" 327 #include "ipc/param_traits_log_macros.h"
311 namespace IPC { 328 namespace IPC {
312 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 329 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
313 #include "content/public/common/common_param_traits_macros.h" 330 #include "content/public/common/common_param_traits_macros.h"
314 } // namespace IPC 331 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698