eval

Javascript prototype undefined after eval deserialization

Attempting to deserialize JSON data and update each object's prototype and inherit a common function. However, the following script throws error "people[0].getFullName is not a function". The prototype for deserialized objects appears to be undefined after assignment. <html> <head> <script> var json = '[ {"firstName": "John", "lastName...

Use of eval in Python?

There is an eval function in Python I stumbled upon while playing around. I cannot think of a case when this function is needed, except maybe as syntactic sugar. Can anyone give an example? Thanks :) ...

Safety of Python 'eval' For List Deserialization

Are there any security exploits that could occur in this scenario: eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False}) where unsanitized_user_input is a str object. The string is user-generated and could be nasty. Assuming our web framework hasn't failed us, it's a real honest-to-god str instance f...

Comparing as2 to as1

For my recent project I need to work with as1. The problem is that I have a little bit forgotten as1, I think my last coding in as1 was nearly 8 years ago. My first question is, is there any web site to refererence as1 syntax or an as2 to as1 guide? Second one is about eval(). Is there is any difference between as2 eval to as1 eval. ...

Binding Eval with an ImageURL in ASP.NET

I'm trying to bind an image using Eval() with VB.NET and ASP.NET, but am running into issues: Code snippet <bri:ThumbViewer Id="Th1" runat="server" ImageUrl='<%# Eval("Name", "~/SiteImages/ram/3/{0}") %>' Height="100px" Width="100px" /> I set strImagePath in the code-behind as: strImagePath ="~/SiteImages/ram/3/" H...

Properly handling spaces and quotes in bash completion

What is the correct/best way of handling spaces and quotes in bash completion? Here’s a simple example. I have a command called words (e.g., a dictionary lookup program) that takes various words as arguments. The supported ‘words’ may actually contain spaces, and are defined in a file called words.dat: foo bar one bar two Here’s my f...

Will jQuery safely evaluate a JSON response to a HTTP POST?

I couldn't find in the jQuery document if any of its AJAX methods SAFELY evaluates a JSON response to a $.post. ...

Find the source of (eval:...) code

I've got code which produces a stack trace at some point: fileA.rb:1670:in `flow_completed_for' (eval):58:in `on_success_res_for_register' fileB:312:in `send' fileC:312:in `request_specific_response_dispatch' ... How can I find the source where on_success_res_for_register was defined? The code is called from some timer and I have prob...

How to create an object from a string in Java (how to eval a string)?

I know eval is "evil", but I'm using it in a way that the user can't ever abuse it. Let's say I've got a string "new Integer(5)". I want to do something such that I can set a variable, let's say foo, to new Integer(5). Something like Integer foo; String bar = "new Integer(5)" *magic happens* System.out.println(foo) -> 5 I've looked ...

PHP eval error when assigning value to variable

Hello, all SO users! I have a bit of PHP code (for the module feature of my CMS (not drupal) which allows people to view pages, comments, forum posts, blog posts, etc...): if(isset($_GET["m"])) { //Does the module exist and activated, and has it a function called view? if(isset($module_exists[$_GET["m"]]) && method_exists($_GET...

PHP: Difference include/eval

If the code is the same, there appears to be a difference between: include 'external.php'; and eval('?> . file_get_contents('external.php') . '<?php); What is the difference? Does anybody know? I am actually pretty sure there is a difference. I just found out. I have got a large piece of ugly generated php in my database*. By cre...

What is the best way to call a python script from another python script?

I have a script named test1.py which is not in a module. It just has code that should execute when the script itself is run. There are no functions, classes, methods etc. I have another script which runs as a service. I want to call test1.py from the script running as a service. eg: test1.py print "I am a test" print "see! I do nothin...

JQUERY evaluate a string

Hi all, I wanted to evaluate this script in jquery: var name = "Brian"; var txt = "This is your {name}"; Anyone can help me? I'm very noob for this one. Thanks ...

What's a more secure alternative for eval() when I just want to call a function?

I know PHP has call_user_func, I was just wondering if JavaScript had something similar, where the method I want to call is, for example: object.set$fieldID($fieldValue) I would rather not go through if/else/switch blocks just to execute one line of code properly. If it helps, I am using jQuery. ...

\r\n vs \n in python eval function

Why eval function doesn't work with \r\n but with \n. for example eval("for i in range(5):\r\n print 'hello'") doesn't work eval("for i in range(5):\n print 'hello'") works I know there is not a problem cause using replace("\r","") is corrected, but someone knows why happens? --Edit-- Oh! sorry , exactly, I meant exec. Carriage r...

What does the special variable $@ mean in Perl?

I'm trying to understand the following piece of code: sub foo { ... if ( $@ ) { ... die $@; } } ...

Is there a way to store a call to various PHP functions in a MySQL database without the risks of using eval()?

I'm building a very basic CMS for a specific project that contains numerous functions such as get_menu(), get_title(), get_recent(), etc. However, I want to be able to store templates, which would be echoed during page load, that contain said functions in the MySQL database. Doing a str_replace for each possible function would be a pit...

In Perl, why do I get a syntax error when I try to use string eval?

Why isn't this working? eval "$response = $ua->request($r);" print "$@"; gives: syntax error at (eval 8) line 1, near "=" ...

Implementing JS Eval in C#

Possible Duplicate: C# eval equivalent? Duplicate of http://stackoverflow.com/questions/4629/c-eval-equivalent How can we Implement JS eval() in C# If possible provide an example.. thank you ...

heredoc with eval code execution

I've tryed a couple of methods to try and get this working but with no luck! I've got a page like this (Example): <?php $jj = <<<END ?> <h1>blah blah</h1> <p> blah blah blah blah blah blah blah <?php include("file.php"); ?> blah blah</p> <?php END; eval('?>'.$jj.'<?php '); ?> this causes no output what so ever, can not think of a sol...