← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1358911] [NEW] Cannot get csrftoken cookie from horizon.cookies

 

Public bug reported:

It seems the new way of working with cookies in javascript is to use the
horizon.cookies object which uses the angular ngCookies module.  I have
run into a problem trying to get the csrftoken cookie from this object
since it seems that ngCookies expects all cookies to be compatible with
JSON.parse.  This cookie is just a string value so when ngCookies tries
to parse it as JSON I get an error:

>> horizon.cookies.get('csrftoken')
<< SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

This specific error message is from Firefox but I get a similar one from
Chrome.

I only found one other place in horizon where horizon.cookies.get is
used and that is for the network topology 'ntp_draw_mode' cookie.  In
this case it works because the cookie seems to be first set using
horizon.cookies.put which ends up storing the cookie with encoded
quotes:

%22small%22

** Affects: horizon
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1358911

Title:
  Cannot get csrftoken cookie from horizon.cookies

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  It seems the new way of working with cookies in javascript is to use
  the horizon.cookies object which uses the angular ngCookies module.  I
  have run into a problem trying to get the csrftoken cookie from this
  object since it seems that ngCookies expects all cookies to be
  compatible with JSON.parse.  This cookie is just a string value so
  when ngCookies tries to parse it as JSON I get an error:

  >> horizon.cookies.get('csrftoken')
  << SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

  This specific error message is from Firefox but I get a similar one
  from Chrome.

  I only found one other place in horizon where horizon.cookies.get is
  used and that is for the network topology 'ntp_draw_mode' cookie.  In
  this case it works because the cookie seems to be first set using
  horizon.cookies.put which ends up storing the cookie with encoded
  quotes:

  %22small%22

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1358911/+subscriptions


Follow ups

References