ISite字符串截取过滤不全修复方法

akiooo 2016-04-10 AM 2487℃ 0条

在使用字符串截取时,只过滤掉了<>,内容并没过滤掉。

例如:

1
{?$StrCut(|cutStr_s|{$List.ViewContent$}|cutStr_e|,100)$}

出来是pstrong关键词位置、密度、处理/strong/pol ?liURL中出现关键词(英文)/li ?li网页标题中出现关键词(1-3个)/li ?li关键词标签中出现关键词(1-3个)/li

此bug修复方法如下:

打开文件 class/Cls_Template.asp

将1565-1582行代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18
????Private?Function?t_RemoveHTML(strHTML)
????????Dim?objRegExp,?Match,?Matches?
????????Set?objRegExp?=?New?Regexp?
????????objRegExp.IgnoreCase?=?True
????????objRegExp.Global?=?True
????????objRegExp.Pattern?=?"<.+?>"
????????Set?Matches?=?objRegExp.Execute(strHTML)?
????????For?Each?Match?in?Matches?
????????????strHtml=Replace(strHTML,Match.Value,"")?
????????Next
????????objRegExp.Pattern?=?"\&.+?;"
????????Set?Matches?=?objRegExp.Execute(strHTML)?
????????For?Each?Match?in?Matches?
????????????strHtml=Replace(strHTML,Match.Value,"")?
????????Next
????????t_RemoveHTML=strHTML?
????????Set?objRegExp?=?Nothing
????End?Function

替换为以下代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23
????Private?Function?t_RemoveHTML(strHTML)
????????Dim?objRegExp,?Match,?Matches?
????????Set?objRegExp?=?New?Regexp?
????????objRegExp.IgnoreCase?=?True
????????objRegExp.Global?=?True
????????objRegExp.Pattern?=?"<.+?>"
????????Set?Matches?=?objRegExp.Execute(strHTML)?
????????For?Each?Match?in?Matches?
????????????strHtml=Replace(strHTML,Match.Value,"")?
????????Next
????????objRegExp.Pattern?=?"&lt;.+?&gt;"
????????Set?Matches?=?objRegExp.Execute(strHTML)?
????????For?Each?Match?in?Matches?
????????????strHtml=Replace(strHTML,Match.Value,"")?
????????Next
????????objRegExp.Pattern?=?"\&.+?;"
????????Set?Matches?=?objRegExp.Execute(strHTML)?
????????For?Each?Match?in?Matches?
????????????strHtml=Replace(strHTML,Match.Value,"")?
????????Next
????????t_RemoveHTML=strHTML?
????????Set?objRegExp?=?Nothing
????End?Function

保存文件,修复完成。

标签: 字符串截取

非特殊说明,本博所有文章均为博主原创,

部分转载有可能忘记标注,如侵犯了您的权益,您可以留言我增加原文出处或删除文档。