diff options
| author | Misko Hevery | 2011-03-09 21:03:11 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-03-11 14:16:52 -0800 | 
| commit | 26bad2bf878e54fa78ff26518d1275a7e0b5b39c (patch) | |
| tree | dd3d7122697df9c9fc5f8955f7cb2d92e6cc909d | |
| parent | d304b0c3df41b3b1e67c2b9d56c02dc95194512d (diff) | |
| download | angular.js-26bad2bf878e54fa78ff26518d1275a7e0b5b39c.tar.bz2 | |
Fixed cookies which contained unescaped '=' would not show up in cookie service.
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | src/Browser.js | 9 | ||||
| -rw-r--r-- | test/BrowserSpecs.js | 10 | 
3 files changed, 12 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b7c3300..550fcae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@  <a name="0.9.13"><a/>  # <angular/> 0.9.13 curdling-stare (in-progress) # - +### Bug Fixes +- Fixed cookies which contained unescaped '=' would not show up in cookie service. diff --git a/src/Browser.js b/src/Browser.js index af87c47d..446944eb 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -280,7 +280,7 @@ function Browser(window, document, body, XHR, $log) {     * @returns {Object} Hash of all cookies (if called without any parameter)     */    self.cookies = function (name, value) { -    var cookieLength, cookieArray, i, keyValue; +    var cookieLength, cookieArray, cookie, i, keyValue, index;      if (name) {        if (value === _undefined) { @@ -307,9 +307,10 @@ function Browser(window, document, body, XHR, $log) {          lastCookies = {};          for (i = 0; i < cookieArray.length; i++) { -          keyValue = cookieArray[i].split("="); -          if (keyValue.length === 2) { //ignore nameless cookies -            lastCookies[unescape(keyValue[0])] = unescape(keyValue[1]); +          cookie = cookieArray[i]; +          index = cookie.indexOf('='); +          if (index > 0) { //ignore nameless cookies +            lastCookies[unescape(cookie.substring(0, index))] = unescape(cookie.substring(index + 1));            }          }        } diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index 96e5a988..c4f49d37 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -168,9 +168,9 @@ describe('browser', function(){      describe('put via cookies(cookieName, string)', function() {        it('should create and store a cookie', function() { -        browser.cookies('cookieName', 'cookieValue'); -        expect(document.cookie).toMatch(/cookieName=cookieValue;? ?/); -        expect(browser.cookies()).toEqual({'cookieName':'cookieValue'}); +        browser.cookies('cookieName', 'cookie=Value'); +        expect(document.cookie).toMatch(/cookieName=cookie%3DValue;? ?/); +        expect(browser.cookies()).toEqual({'cookieName':'cookie=Value'});        }); @@ -263,8 +263,8 @@ describe('browser', function(){        it ('should return a value for an existing cookie', function() { -        document.cookie = "foo=bar"; -        expect(browser.cookies().foo).toEqual('bar'); +        document.cookie = "foo=bar=baz"; +        expect(browser.cookies().foo).toEqual('bar=baz');        });  | 
