JQuery 移动应用 - 表单安全问题
我正在使用 jquery mobile 构建我的第一个应用程序,其中涉及用户将信息输入表单,然后将其存储在 sqlite 数据库中。我计划用phonegap 来部署它。
我应该采取哪些措施来确保表单中不会输入恶意代码?
如果我理解正确的话,我不能将服务器端脚本与phonegap一起使用。
我知道这可能是以这种方式编写应用程序的陷阱之一......
I'm building my first app using jquery mobile, which involves users entering info into a form, which is then stored in an sqlite database. I plan on deploying it with phonegap.
What measures should I be taking to make sure malicious code isn't entered into the form?
I can't use server-side scripting with phonegap if I understand correctly.
I'm aware this is possibly one of the pitfalls of coding an app this way...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您只是将这些数据存储在 SQLite DB 中,并且不对其进行任何其他操作,那么实际上您唯一需要清理数据的就是 SQL 注入攻击;这是Google 提供的一个简单示例。
Assuming you are simply storing this data in a SQLite DB and doing nothing else with it, really the only thing you have to sanitize the data for would be SQL injection attacks; here's a quick example that Google brings up.
Phonegap 在自己的环境中运行您的代码,该环境没有任何工具来修改或破坏您的 JavaScript 代码。虽然我觉得很奇怪 - 你可以用 javascript 清理你的输入,只要它位于发送它们的同一个函数中(这样程序流程设计的错误就不会导致它被跳过)
Phonegap runs your code in its own environment which doesn't have any tools to modify or break your JavaScript code. And although I feen weird saying that - you can sanitize your inputs with javascript as long as it's in the same function that sends them (so that no error of program flow design can cause it to be skipped)
您可以使用 AJAX 进行服务器端验证,只需在提交时发送所有字段,如果错误显示需要修复的内容,否则提交
You could use AJAX for server side validation, just send all the fields over on submission, if error display what needs to be fixed, else submit