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

fix($browser): colon in url causes infinite digest in FF #8734

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Browser(window, document, $log, $sniffer) {
// URL API
//////////////////////////////////////////////////////////////

var lastBrowserUrl = location.href,
var lastBrowserUrl = location.href.replace(/%3A/g, ":"),
baseElement = document.find('base'),
newLocation = null;

Expand Down Expand Up @@ -175,7 +175,7 @@ function Browser(window, document, $log, $sniffer) {
// - newLocation is a workaround for an IE7-9 issue with location.replace and location.href
// methods not updating location.href synchronously.
// - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172
return newLocation || location.href.replace(/%27/g,"'");
return newLocation || location.href.replace(/%27/g,"'").replace(/%3A/g, ":");
}
};

Expand Down
5 changes: 5 additions & 0 deletions test/ng/browserSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ describe('browser', function() {
expect(browser.url()).toBe("http://ff-bug/?single'quote");
});

it('should decode colons to work around FF bug', function() {
fakeWindow.location.href = "http://ff-bug/?https%3Awww.google.com";
expect(browser.url()).toBe("http://ff-bug/?https:www.google.com");
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is also not verifying that you're preventing an infinite digest error, which is what this bug is about. We need to be able to reproduce the infdig condition

Copy link
Contributor

Choose a reason for hiding this comment

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

I just tried to mimic the described FF behavior without angular. The test
looks fishy to me. It just test that we rewrite the url without actually
reproducing the browser issue. That would be fine if at least we could
repro the browser issue in isolation but we can't.
On Aug 22, 2014 5:50 PM, "Caitlin Potter" notifications@github.com wrote:

In test/ng/browserSpecs.js:

@@ -466,6 +466,11 @@ describe('browser', function() {
expect(browser.url()).toBe("http://ff-bug/?single'quote");
});

  • it('should decode colons to work around FF bug', function() {
  •  fakeWindow.location.href = "http://ff-bug/?https%3Awww.google.com";
    
  •  expect(browser.url()).toBe("http://ff-bug/?https:www.google.com");
    

This test is also not verifying that you're preventing an infinite digest
error, which is what this bug is about


Reply to this email directly or view it on GitHub
https://github.com/angular/angular.js/pull/8734/files#r16627434.

});

it('should not set URL when the URL is already set', function() {
var current = fakeWindow.location.href;
sniffer.history = false;
Expand Down