Index: components/sessions/content/content_serialized_navigation_driver.cc |
diff --git a/components/sessions/content/content_serialized_navigation_driver.cc b/components/sessions/content/content_serialized_navigation_driver.cc |
index 0c682f499029a387291c2c2bd898b6d2c65d2845..236eb28652836afbf0225d26937a85866c6e2658 100644 |
--- a/components/sessions/content/content_serialized_navigation_driver.cc |
+++ b/components/sessions/content/content_serialized_navigation_driver.cc |
@@ -100,10 +100,14 @@ void ContentSerializedNavigationDriver::Sanitize( |
content::Referrer::SanitizeForRequest(navigation->virtual_url_, |
old_referrer); |
+ bool page_state_is_valid = navigation->encoded_page_state_.empty() || |
+ content::PageState::CreateFromEncodedData( |
+ navigation->encoded_page_state_).IsValid(); |
+ |
// No need to compare the policy, as it doesn't change during |
// sanitization. If there has been a change, the referrer needs to be |
// stripped from the page state as well. |
- if (navigation->referrer_url_ != new_referrer.url) { |
+ if (navigation->referrer_url_ != new_referrer.url || !page_state_is_valid) { |
navigation->referrer_url_ = GURL(); |
navigation->referrer_policy_ = GetDefaultReferrerPolicy(); |
navigation->encoded_page_state_ = |