We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# update if(self.__check("data") and statement == "data:save"): sets = "" for data in self.__protected["__data"]: sets = sets + "%s = '%s', " % (data, self.__valuefix(self.__protected["__data"][data])) sets = sets.strip().rstrip(",") sql = sql + " SET %s" % sets # insert if(self.__check("data") and statement == "data:add"): sets = "" values = "" for data in self.__protected["__data"]: sets = sets + "%s, " % data values = values + "'%s', " % self.__valuefix(self.__protected["__data"][data]) sets = sets.strip().rstrip(",") values = values.strip().rstrip(",") sql = sql + " (%s)" % sets sql = sql + " VALUES (%s)" % values
如上,当update或者insert的值是None的时候,照样被带入sql语句了,这样会导致数据库报错。
以update为例子,假设self.__protected["__data"][data]=None,那么就会生成语句update tablename set data = None where ...这样会让数据库报错!
self.__protected["__data"][data]=None
update tablename set data = None where ...
修复方案: 应该先判断一下self.__protected["__data"][data]=None中的值是否为None,否则不执行下面的生成SQL的语句,insert操作处的修改也一样!
希望作者详细测试一下!
The text was updated successfully, but these errors were encountered:
另外,仔细看过一遍这个 lib/query.py 发现 SQL 语句是拼接式的,一不小心就会有 SQL注入啊
建议重新规划一下代码,改成 prepare statement 的形式
Sorry, something went wrong.
No branches or pull requests
如上,当update或者insert的值是None的时候,照样被带入sql语句了,这样会导致数据库报错。
以update为例子,假设
self.__protected["__data"][data]=None
,那么就会生成语句update tablename set data = None where ...
这样会让数据库报错!修复方案:
应该先判断一下
self.__protected["__data"][data]=None
中的值是否为None,否则不执行下面的生成SQL的语句,insert操作处的修改也一样!希望作者详细测试一下!
The text was updated successfully, but these errors were encountered: