Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,我需要允许用户进行计算,例如从不同表中的行中添加/减去/除值。有比使用 eval() 更安全的方法吗?将字符串作为输入并编写我自己的函数来解析字符串进行计算会更好吗?
只过滤掉非数字和非操作数
var1 = "4+4;haha i'm a nasty command" var1.gsub!(/[^\d|\+-\/\*]/,"") p eval(var1) => 8
是的。与您不应直接使用用户输入进行 SQL 查询以避免 sql 注入的原因相同:在这种情况下,您不应该这样做以避免代码注入。ii
table放入a标签是一个好的解决方案吗?为什么链接在包装表时不起作用?
table
a
<a href="/place"> <table> <tr> <td> <span class="place-icon" /> </td> <td
1 design-patterns - 不需要 UI 时的设计模式
3 perl - 使用 perl 检索与相同 ID 匹配的值
4 python - SQLAlchemy:表已经存在
Reference php × 1429865 c/c++ × 756500 nginx × 49975 mongodb × 159057 mybatis × 3233 anaconda × 13410 pycharm × 14671 python × 1902243 vscode × 56040 docker × 110988 github × 49000 flask × 49129 ffmpeg × 24037 jmeter × 16910 matplotlib × 63493 bootstrap × 54641