中华考试网·阅读新闻
编程开发 > ASP > 文章内容

ASP编码教程:asp中实现清除html的函数

2015-4-8编辑:ljnbset

这个函数是必需要的,很多黑客来捣乱,黑掉数据库,会注入大量的病毒js,在存储和展示文本数据的时候,使用此函数过滤一下,可避免不少麻烦

clearhtml代码

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

'清除HTML代码

function clearhtml(content)

  content=replacehtml("&#[^>]*;","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml(" ","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("(javascript|jscript|vbscript|vbs):","",content)

  content=replacehtml("on(mouse|exit|error|click|key)","",content)

  content=replacehtml("<\\?xml[^>]*>","",content)

  content=replacehtml("<\/?[a-z]+:[^>]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  content=replacehtml("]*>","",content)

  clearhtml=content

end function

replacehtml代码

?

1

2

3

4

5

6

7

8

9

10

function replacehtml(patrn,strng,content)  

  if isnull(content) then

    content=""

  end if

  set regex=new regexp

  regex.pattern=patrn

  regex.ignorecase=true

  regex.global=true

  replacehtml=regex.replace(content,strng)

end function

使用方法:

复制代码 代码如下:


<%=clearhtml("

分享代码提示(2)

  • 添加完代码必须点击“完成并查看”生效
  • 准确的编程语言,可正确对代码语法着色
  • 输入简单几个字的代码片段说明
  • 上传源码文件时无需再输入说明
  • 非程序相关文件将直接删除,严重封帐号
  • 图片仅用来上传截图之类的文件,勿作他途
")%>

以上就是本文所述的全部内容了,希望大家能够喜欢。

ASP编码教程:asp实现截取字符串函数
咨询热线:4000-525-585(免长途费)