我有以下like用于搜索博客的查询.如果我这样做,我不确定自己是否容易受到SQL注入攻击.SQLAlchemy如何处理这个问题?安全吗?
search_results = Blog.query.with_entities(Blog.blog_title).filter(Blog.blog_title.like("%"+ searchQuery['queryText'] +"%")).all()
Run Code Online (Sandbox Code Playgroud) 我正在开发一个用于redux-axios-middleware执行 XHR 请求的 React 应用程序。它的设置方式与客户端类似,如下所示index.js:
const client = axios.create({ //all axios can be used, shown in axios documentation
baseURL:'https://api.vktest.xxx/api',
responseType: 'json',
validateStatus: function (status) {
return status >= 200 && status < 300
}
});
const axiosMiddle = axiosMiddleware(client)
export const store = createStore(rootReducer, composeEnhancers(applyMiddleware(thunk, axiosMiddle)))
Run Code Online (Sandbox Code Playgroud)
然后,我从我的组件中调用我的操作,如下所示:
store.dispatch(loginAction(credentials))
这是动作:
import { LOGIN } from './types'
export function loginAction(credentials) {
return dispatch => {
return dispatch(doLogin(credentials) ).then(
response => {
dispatch({type: 'LOGIN_SUCCESS', response})
},
error => { …Run Code Online (Sandbox Code Playgroud) 我正在开发一种从API检索JPG并对其进行处理的工具。无法信任图片的来源,我想测试图片是否为有效的JPG(这是允许的唯一图片类型)。
我遇到了无法修复的PIL错误。下面是我的代码:
image = StringIO(base64.b64decode(download['file']))
img = Image.open(image)
if img.verify():
print 'Valid image'
else:
print 'Invalid image'
Run Code Online (Sandbox Code Playgroud)
但是,似乎img.verify()返回None。我可以在打开的图像上调用其他函数,例如返回大小的img.size()。当我尝试调试代码时,得到以下输出:
img = Image.open(image)
print img
print img.size()
print img.verify()
[2018-01-09 20:56:43,715: WARNING/Worker-1] <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=2577x1715 at 0x7F16E17DC9D0>
[2018-01-09 20:56:43,716: WARNING/Worker-1] (2577, 1715)
[2018-01-09 20:56:43,716: WARNING/Worker-1] None
Run Code Online (Sandbox Code Playgroud)
有人遇到过同样的问题吗?