destoon采集论坛

 找回密码
 立即注册
查看: 353|回复: 0

限制用户输入的CR和LF

[复制链接]

2

主题

0

回帖

18

积分

新手上路

Rank: 1

积分
18
发表于 2014-3-24 14:05:10 | 显示全部楼层 |阅读模式
解决方案:        
-修复的基本思路:
  限制用户输入的CR和LF,或者对CR和LF字符正确编码后再输出,以防止注入自定义HTTP头。
-PHP语言的解决方案:
  这种现象往往表现在带有参数传递的网页,只要合理的过滤好就OK啦,PHP语言的一些过滤方法:
  $post = trim($post);
  $post = strip_tags($post,""); //清除HTML等代码
  $post = ereg_replace("\t","",$post); //去掉制表符号
  $post = ereg_replace("\r\n","",$post); //去掉回车换行符号
  $post = ereg_replace("\r","",$post); //去掉回车
  $post = ereg_replace("\n","",$post); //去掉换行
  $post = ereg_replace(" ","",$post); //去掉空格
  $post = ereg_replace("'","",$post); //去掉单引号
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|destoon采集论坛

GMT+8, 2025-11-23 05:51 , Processed in 0.019155 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表