Calling eval() in a page-action

91 views
Skip to first unread message

dashman

unread,
Aug 13, 2012, 11:51:22 AM8/13/12
to chromium-...@chromium.org
I'm calling the following in a page-action page.
where my_string is a JSON string.

eval( "(" + my_string + ")" )

I'm getting the following error message

Uncaught Error: Code generation from strings disallowed for this context

This is with the new chrome release - used to work before.

Joshua Woodward

unread,
Aug 13, 2012, 12:12:11 PM8/13/12
to dashman, chromium-...@chromium.org
you can't use eval()

how are you getting your JSON string? Dynamically creating, via http request, leprechauns?
is it a valid JSON?
have you tried JSON.parse() ?

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/-/8mbEQXgMCjoJ.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.



--



Twitter - @howtohtml5

dashman

unread,
Aug 13, 2012, 2:57:42 PM8/13/12
to chromium-...@chromium.org, dashman
i'm getting it from a http request.

actually it's the body of a http GET and yes it's valid...always
worked.

with manifest v2 - it's being flagged.

any suggestions for a workaround.

i.e. i have a JSON string and want to parse it into a object.



Adam Barth

unread,
Aug 13, 2012, 2:58:43 PM8/13/12
to dashman, chromium-...@chromium.org
You might want to try JSON.parse(...).

Adam

dashman

unread,
Aug 13, 2012, 3:34:42 PM8/13/12
to chromium-...@chromium.org, dashman
tried that and it worked after some mods.

"{ status: 0 }" does not work.


'{ "status": 0 }' works - i.e. enclose attribute in double quotes.

Joshua Woodward

unread,
Aug 13, 2012, 3:37:51 PM8/13/12
to dashman, chromium-...@chromium.org
On Mon, Aug 13, 2012 at 12:34 PM, dashman <erjd...@gmail.com> wrote:
"{ status: 0 }" does not work.


Not valid JSON

 

'{ "status": 0 }' works - i.e. enclose attribute in double quotes.

Is Valid JSON
Reply all
Reply to author
Forward
0 new messages