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

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)
@@ -51,6 +51,7 @@
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars);
m->WriteString(p.possibly_invalid_spec());
+ m->WriteBool(p.is_valid());
// TODO(brettw) bug 684583: Add encoding for query params.
}
@@ -60,7 +61,20 @@
*p = GURL();
return false;
}
+
*p = GURL(s);
+
+ // Backwards compatibility with automation bots: permit older messages
+ // that don't contain the is_valid flag without returing an error.
+ bool is_valid;
+ if (m->ReadBool(iter, &is_valid)) {
+ // GURL doesn't always have print-parse consistency; beware of an invalid
+ // URL magically become valid.
+ if (p->is_valid() && !is_valid) {
+ DLOG(WARNING) << "GURL string " << s << " (marked invalid) parsed valid.";
+ *p = GURL();
brettw 2012/12/17 18:53:23 If we're going to do this, why not just have Write
+ }
+ }
return true;
}
« 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