我正在编写一个快速的 web.py 应用程序并从 web.input 中获取数据......
import web
urls = (
'/', 'something',
)
app = web.application(urls, globals())
db = web.database(dbn='postgres', db='database', user='username', password='password', host='127.0.0.1')
class something:
def GET(self):
i = web.input()
return db.select('foo.table', where="column=$variable", vars={'variable':i.input, })
if __name__ == "__main__": app.run()
我是否应该担心将 i.input 传递给 db.select (或查询等),就像我作为 vars 的一部分一样?SQL 注入的可能性等?
编辑:我自己一直在玩这个,试图让一些讨厌的事情发生。例如,使用引用http://localhost:8080/?id=13' 或 'x' ='x会导致很好地转义的 sql 显示在 Exceptions 中:
<sql: 'select * from foo.table where id = "13\' or \'x\'=\'x"'>
我尝试了互联网提出的其他一些常见测试,并认为我很高兴 web.py 正在处理卫生问题......其他人可以发表评论吗?