@@ -283,7 +283,7 @@ describe('browser', function() {
283
283
expect ( oldVal ) . not . toBeDefined ( ) ;
284
284
} ) ;
285
285
286
- it ( 'should escape both name and value' , function ( ) {
286
+ it ( 'should encode both name and value' , function ( ) {
287
287
browser . cookies ( 'cookie1=' , 'val;ue' ) ;
288
288
browser . cookies ( 'cookie2=bar;baz' , 'val=ue' ) ;
289
289
@@ -359,7 +359,7 @@ describe('browser', function() {
359
359
expect ( browser . cookies ( ) [ 'foo' ] ) . toBe ( '"first"' ) ;
360
360
} ) ;
361
361
362
- it ( 'should unescape cookie values that were escaped by puts' , function ( ) {
362
+ it ( 'should decode cookie values that were encoded by puts' , function ( ) {
363
363
document . cookie = "cookie2%3Dbar%3Bbaz=val%3Due;path=/" ;
364
364
expect ( browser . cookies ( ) [ 'cookie2=bar;baz' ] ) . toEqual ( 'val=ue' ) ;
365
365
} ) ;
@@ -371,10 +371,16 @@ describe('browser', function() {
371
371
expect ( browser . cookies ( ) [ 'cookie name' ] ) . not . toBeDefined ( ) ;
372
372
} ) ;
373
373
374
- it ( 'should unscape special characters in cookie values' , function ( ) {
374
+ it ( 'should decode special characters in cookie values' , function ( ) {
375
375
document . cookie = 'cookie_name=cookie_value_%E2%82%AC' ;
376
376
expect ( browser . cookies ( ) [ 'cookie_name' ] ) . toEqual ( 'cookie_value_€' ) ;
377
377
} ) ;
378
+
379
+ it ( 'should not decode cookie values that do not appear to be encoded' , function ( ) {
380
+ // see #9211 - sometimes cookies contain a value that causes decodeURIComponent to throw
381
+ document . cookie = 'cookie_name=cookie_value_%XX' ;
382
+ expect ( browser . cookies ( ) [ 'cookie_name' ] ) . toEqual ( 'cookie_value_%XX' ) ;
383
+ } ) ;
378
384
} ) ;
379
385
380
386
0 commit comments