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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/common_param_traits.cc
===================================================================
--- content/public/common/common_param_traits.cc (revision 172151)
+++ content/public/common/common_param_traits.cc (working copy)
@@ -50,6 +50,22 @@
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars);
+
+ // Beware of print-parse inconsistency which would change an invalid
+ // URL into a valid one. Ideally, the message would contain this flag
+ // so that the read side could make the check, but performing it here
+ // avoids changing the on-the-wire representation of such a fundamental
+ // type as GURL.
brettw 2012/12/17 20:25:00 Can you file a bug for doing said improvements and
Tom Sepez 2012/12/17 20:53:38 Done.
+ if (!p.is_valid()) {
+ GURL reconstructed_url(p.possibly_invalid_spec());
+ if (reconstructed_url.is_valid()) {
+ DLOG(WARNING) << "GURL string " << p.possibly_invalid_spec()
+ << " (marked invalid) but parsed as valid.";
+ m->WriteString("");
brettw 2012/12/17 20:25:00 Can you do WriteString(std::string()) instead?
Tom Sepez 2012/12/17 20:53:38 Done.
+ return;
+ }
+ }
+
m->WriteString(p.possibly_invalid_spec());
// TODO(brettw) bug 684583: Add encoding for query params.
}
« 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