eval

Javascript prototype undefined after eval deserialization

自闭症网瘾萝莉.ら 提交于 2019-12-06 03:45:42
问题 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": "Smith"}, {"firstName": "Nancy", "lastName": "Jones"} ]'; var people; eval('people = ' + json); function Person() { } Person.prototype.getFullName = function

How can I avoid using 'eval' in conjunction with 'git-for-each-ref'?

左心房为你撑大大i 提交于 2019-12-06 02:40:12
Most advanced uses of git for-each-ref that I've come across involve eval . For instance, the last example in the git-for-each-ref man page uses eval in order to execute the contents of the fmt variable: #!/bin/sh fmt=' r=%(refname) # ... omitted, for conciseness ... ' eval=`git for-each-ref --shell --format="$fmt" \ # ... omitted, for conciseness ... refs/tags` eval "$eval" However, the use of eval is associated with security risks ; avoiding it, whenever possible, is considered good practice. Here is a real example, adapted from this answer : #!/bin/sh fmt=' ref=%(refname:short) if git merge

How to use square brackets for a string evaluation in VBA?

人盡茶涼 提交于 2019-12-06 02:29:54
问题 Using square brackets for string evaluation, I am trying to make [inputString] return 320 . Any ideas how to do it? Public Sub TestMe() Dim inputString As String inputString = "20+300" Debug.Print Application.Evaluate(inputString) 'ok Debug.Print Evaluate([inputString]) 'ok Debug.Print [20+300] 'ok Debug.Print ["20"+"300"] 'ok Debug.Print ["20"+300] 'ok Debug.Print [inputString] 'returns "20+300" and not 320 End Sub 回答1: From the link in the comment: "Using square brackets (for example, "[A1

Eval(), what's the point?

99封情书 提交于 2019-12-06 01:37:01
问题 The Official Documentation regarding eval() as function, says: Among other things, this can be useful for storing code in a database text field for later execution. I'm seriously confused about that. Is PHP Documentation suggesting to store PHP lines into databases? What? Isn't that something freaking unsafe? What if i know that in the database there's a string that is executed as PHP? Isn't that extremely dangerous? I just need of an Sql injection to do whatever i want to that site, whatever

How do I execute Dynamically (like Eval) in Dart?

流过昼夜 提交于 2019-12-06 01:33:14
Since getting started in Dart I've been watching for a way to execute Dart (Text) Source (that the same program may well be generating dynamically) as Code. Like the infamous "eval()" function. Recently I have caught a few hints that the communication port between Isolates support some sort of "Spawn" that seems like it could allow this "trick". In Ruby there is also the possibility to load a module dynamically as a language feature, perhaps there is some way to do this in Dart? Any clues or a simple example will be greatly appreciated. Thanks in advance! Ladislav Thon provided this answer (on

In R6RS Scheme, is there a way to get the current environment for use with eval?

a 夏天 提交于 2019-12-06 01:27:25
问题 Is there any way in R6RS Scheme to obtain the current environment and then pass it as the second argument to eval ? For example, what should the question marks be for the following expression to return 9? (let ((x 4) (y 5)) (eval '(+ x y) ???)) 回答1: No, there is no such thing in R6RS. Some rare implementations might support something like that, but in the overwhelming majority (including eval in other languages!) this cannot be done. The reason for that is simple: it breaks compilation, since

Using an environment variable to pass arguments to a command

一笑奈何 提交于 2019-12-06 01:01:49
I'm trying to write a bash script that takes an environment variable and passes it along to a command. So if I had something like: export OUT="-a=arg1 -b=\"arg2.0 arg2.1\"" I want in my bash script to do something like: <command> -a=arg1 '-b=arg2.0 arg2.1' I have one approach that seems to do this, but it involves using eval: eval <command> ${OUT} If I include set -x right about the command, I will see: + eval <command> a=arg1 'b="arg2.0' 'arg2.1"' ++ <command> -a=arg1 '-b=arg2.0 arg.1' However, I've poked around the dangers of using eval and since this will be taking the arguments from user

PHP EVAL - Fixing an Insecurity

不问归期 提交于 2019-12-06 00:02:47
We have a system that has to perform calculations that user input provides. The easiest way I have found to do one of those calculations is eval -- trying to figure out a parser for: (3 + 6 ) / 2 + 27 * 5 / 2 Just seems difficult. If anyone has a solution to this -- I would be happy to hear it. Assuming you are going with EVAL (I know its the dreaded function) it would be a major insecurity to allow them to type whatever they want in that box. So, I pose the question, if I did a regex removing everything besides numbers, standard operators (+ - / *) and parentheses, something like $equation =

alternatives to eval for running remote code

让人想犯罪 __ 提交于 2019-12-05 23:27:39
Are there any alternatives to using eval to immediatly run remote & trusted javascript code. function load(filePath) { var o = $.ajax({ url: filePath, dataType: 'html', async: false }); eval(o.responseText); } load("somePath"); // run a function that relies on the code from o.responseText being loaded doSomethingWithCode(); I'm aware that synchronous loading of javascript is adviced againts. But if there is no choice are there any cross browser alternatives for the use of eval above. [Edit] To clarify in more detail the code being loaded is a self executing function. Which needs to execute

Custom parsing function PHP

只愿长相守 提交于 2019-12-05 23:08:22
I'm trying to remove eval from the following function. I tried with sprintf and ${} , but still cannot find a solution. Here the function: function parseDbString(string $value = 'Looking for a good {{ $pippo }}'){ $pippo='Pizza'; return preg_replace_callback('/{{(.*?)}}/', function($res) use ($pippo) { // $val=${trim($res[1])}; Returns "Undefined variable: $pippo" $val=@eval("return ".trim($res[1]).";"); // Returns "Looking for a good Pizza" return isset($val) ? $val : $res[0]; },$value); } So, yes, eval() is often detested as one of the highest order "evils" in php. In most cases, when a task