eval

Why do some forms of indirect eval fail in Opera and Safari?

假装没事ソ 提交于 2019-12-14 04:19:06
问题 Some forms of indirect eval fail in Opera, and, I'm told, in Safari. [eval][0]('') Unhandled Error: eval called with invalid this object Notice that it fails when evaluating an empty string... as far as I can tell it should return undefined . Other forms, like (0,eval)('') , seem to work fine. Running the examples from this test suite by kangax, I see several forms that fail with the "invalid this object" message in Opera, but not Chrome or Firefox. Can anyone explain why this happens? What

exec name “templet_1h” is not defined

半城伤御伤魂 提交于 2019-12-14 04:05:32
问题 I'm trying to write a code with exec and eval function to read lists of variables from a numpy .npz file. When I ran the code without defining it as a function def, the code worked. However, when I ran the code as a function, i.e. read_file_npz("file_address") , the python 3.7 kept pop up message saying that templet_1h was not defined. def read_file_npz(file_names_2): import numpy as np Delete_elements=["arr_0"] evaluate_1= "templet_1h=np.load(\"./" +file_names_2+ ".npz\")"; exec(evaluate_1)

makefile variable assignment under a target

假装没事ソ 提交于 2019-12-14 03:46:57
问题 I was running the following commands in a target in my Makefile. target1: <run some command which creates ids.log> $(eval id1 := $(shell cat ids.log | head -1)) @echo id is $(id1) <some other command which uses the value $(id1)> My task is to get the first line in "ids.log" and keep it in a variable id1, so that I can use the value in the command I will execute next in this target. I get an error running this command "cat: ids.log: No such file or directory". Looks like $(eval .. ) command is

Risks of using PHP eval for string math

非 Y 不嫁゛ 提交于 2019-12-14 03:37:48
问题 I have a question about eval() secourity risks This is my own code <?php $str = 'nabi<'.$_GET['hackme']; // $_GET['hackme']=2; $str = str_replace("nabi", 1, $str); $hmm = eval('return ('.$str.');'); if($hmm){ echo 'yeah'; } else{ echo 'no'; } Result is will be: yeah My code workes well It's what i want! But i am afraid of the security risks! Please offer a new solution 回答1: If all you're doing is checking if something is less than 1, typecast $_GET['hackme'] to int or double. $str = 'nabi<' .

Eval/Bind TimeOfDay property without milliseconds?

↘锁芯ラ 提交于 2019-12-14 03:00:26
问题 I'm trying to format the following: <%# Bind("TimeOfDay","{0:HH:mm:ss}") %> <%# Eval("TimeOfDay","{0:HH:mm:ss}") %> <%# Bind("TimeOfDay","{0:HH:mm:ss tt}") %> But using either of those returns time as following: 08:33:08.1430000 How can I only get the 08:33:08 part? Thanks, EtonB. 回答1: ((DateTime)Eval("TimeOfDay")).ToString("HH:mm:ss") ? 来源: https://stackoverflow.com/questions/3970154/eval-bind-timeofday-property-without-milliseconds

Is my eval implementation completely safe? [duplicate]

一曲冷凌霜 提交于 2019-12-13 18:22:51
问题 This question already has answers here : Python: make eval safe [duplicate] (4 answers) Closed 5 years ago . I have a code, in which I want let the user to pass through stdin three values, each of type float , Fraction or int , so I can't apply ast.literal_eval on input to get result I want. I read Eval really is dangerous, showing how eval 's weaknesses can be used by person who gives input, and some ways how to make eval invokes more safe. I applyed author's advices and wrote this code,

Why is context inside non-interactive Function object different in node.js?

自作多情 提交于 2019-12-13 17:22:39
问题 I'd like to create a function from string that requires another module (don't ask). When I try to do that in node interactive shell, everything is fine and dandy: > f = new Function("return require('crypto')"); [Function] > f.call() { Credentials: [Function: Credentials], (...) prng: [Function] } However, when I put the exact same code in file, I am told that require function is not avaliable: israfel:apiary almad$ node test.coffee undefined:2 return require('crypto') ^ ReferenceError:

Eval not working on unexpanded macro quote

跟風遠走 提交于 2019-12-13 17:03:51
问题 In common lisp I can do this: src-> (defmacro macro-hello () `"hello") (eval '(macro-hello)) no problem. In clojure: (defmacro macro-hello [] `"hello") (eval '(macro-hello)) gives me an error. Have I done something wrong? Clojure Error: Exception in thread "main" java.lang.Exception: Unable to resolve symbol: macro-hello in this context (NO_SOURCE_FILE:12) at clojure.lang.Compiler.analyze(Compiler.java:4340) at clojure.lang.Compiler.analyze(Compiler.java:4286) at clojure.lang.Compiler

Parent eval (reader) function in Clojure source?

柔情痞子 提交于 2019-12-13 13:13:06
问题 In Peter Norvig's epic tome Paradigms of Artifical Intelligence Programming in Chapter 7 - he describes a function interp which is effectively a simple eval function used when interpreting a bare-bones Scheme in a REPL. (defun interp (x &optional env) "Interpret (evaluate) the expression x in the environment env." (cond ((symbolp x) (get-var x env)) ((atom x) x) ((case (first x) (QUOTE (second x)) (BEGIN (last1 (mapcar #'(lambda (y) (interp y env)) (rest x)))) (SET! (set-var! (second x)

Node.JS vm.runInNewContext() vs require() and eval()

大城市里の小女人 提交于 2019-12-13 11:43:26
问题 Is vm.runInNewContext considered black magic like eval ? Is there a significant performance difference between require and reading a file and using vm to run it or is the the same under the hood (if you implemented caching etc and just wanted to add some variables to the context) 回答1: runInNewContext is not meant to be used as a replacement of require or eval , but instead as a way to create a sandbox environment where you can safely run other scripts. Disadvantages are that it's slow