Skip to content

Commit

Permalink
Beware of print-read inconsistency when serializing GURLs.
Browse files Browse the repository at this point in the history
BUG=165622


Review URL: https://chromiumcodereview.appspot.com/11576038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173583 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tsepez@chromium.org committed Dec 18, 2012
1 parent 2a57ab3 commit 74aaa70
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions content/public/common/common_param_traits.cc
Expand Up @@ -50,6 +50,23 @@ namespace IPC {

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. See https://crbug.com/166486 for additional work in
// this area.
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(std::string());
return;
}
}

m->WriteString(p.possibly_invalid_spec());
// TODO(brettw) bug 684583: Add encoding for query params.
}
Expand Down

0 comments on commit 74aaa70

Please sign in to comment.