Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($location): re-assign location after BFCache back
Browse files Browse the repository at this point in the history
In the Android browser, the BFCache maintains
the state of JavaScript applications even when
navigating to another app, so that going
forward and back, to and from an application
is very fast.

Unfortunately, this can have undesired side
effects. In this instance, the location
variable was holding a reference to a stale
window.location, and was throwing errors
when going back to an Angular app after
browsing to another site.

This fix makes sure that location.url()
includes a check to make sure that location
is referencing the current window.location.

Closes #4044
  • Loading branch information
jeffbcross committed Sep 30, 2013
1 parent 8727fce commit 2ebf931
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ function Browser(window, document, $log, $sniffer) {
* @param {boolean=} replace Should new url replace current history record ?
*/
self.url = function(url, replace) {
// Android Browser BFCache causes location reference to become stale.
if (location !== window.location) location = window.location;

// setter
if (url) {
if (lastBrowserUrl == url) return;
Expand Down

1 comment on commit 2ebf931

@agileurbanite
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffbcross this seems to throw a xss warning when I run it against security scans, any thoughts on why this might not actually be a concern?

Please sign in to comment.