ASP を作成するときは、ハッカーによる悪用を防ぐために特殊な文字列の処理に注意を払う必要があります。 aspを使っている友人はぜひ参考にしてみてください。次のようにコードをコピーします。
'======================================
'事故を防ぐためにコンテンツを変換する
'======================================
関数 Content_Encode(ByVal t0)
ISNull(t0) または Len(t0)=0 の場合
コンテンツエンコード=
それ以外
Content_Encode=置換(t0,<,<)
Content_Encode=Replace(Content_Encode,>,>)
終了IF
終了機能
'======================================
'コンテンツの変換を解除する
'======================================
関数 Content_Decode(ByVal t0)
ISNull(t0) または Len(t0)=0 の場合
コンテンツ_デコード=
それ以外
Content_Decode=置換(t0,<,<)
Content_Decode=Replace(Content_Decode,>,>)
終了IF
終了機能
'======================================
'文字をフィルタリングする
'======================================
関数 FilterText(ByVal t0,ByVal t1)
IF Len(t0)=0 または IsNull(t0) または IsArray(t0) then FilterText=:Exit 関数
t0=トリム(t0)
ケース t1 を選択してください
ケース1
t0=置換(t0,Chr(32), )
t0=置換(t0,Chr(13),)
t0=置換(t0,Chr(10)&Chr(10),<br>)
t0=置換(t0,Chr(10),<br>)
ケース2
t0=置換(t0,Chr(8),)'return
t0=Replace(t0,Chr(9),)'tab(水平タブ文字)
t0=置換(t0,Chr(10),)'改行
t0=Replace(t0,Chr(11),)'tab(垂直タブ)
t0=Replace(t0,Chr(12),)'ページ変更
t0=Replace(t0,Chr(13),)' キャリッジリターン chr(13)&chr(10) キャリッジリターンとラインフィードの組み合わせ
t0=置換(t0,Chr(22),)
t0=Replace(t0,Chr(32),)'SPACE
t0=置換(t0,Chr(33),)'!
t0=置換(t0,Chr(34),)'
t0=置換(t0,Chr(35),)'#
t0=置換(t0,Chr(36),)'$
t0=置換(t0,Chr(37),)'%
t0=置換(t0,Chr(38),)'&
t0=置換(t0,Chr(39),)''
t0=置換(t0,Chr(40),)'(
t0=置換(t0,Chr(41),)')
t0=置換(t0,Chr(42),)'*
t0=置換(t0,Chr(43),)'+
t0=置換(t0,Chr(44),)',
t0=置換(t0,Chr(45),)'-
t0=置換(t0,Chr(46),)'。
t0=置換(t0,Chr(47),)'/
t0=置換(t0,Chr(58),)':
t0=置換(t0,Chr(59),)';
t0=置換(t0,Chr(60),)'<
t0=置換(t0,Chr(61),)'=
t0=置換(t0,Chr(62),)'>
t0=置換(t0,Chr(63),)'?
t0=置換(t0,Chr(64),)'@
t0=置換(t0,Chr(91),)'/
t0=置換(t0,Chr(92),)'/
t0=置換(t0,Chr(93),)']
t0=置換(t0,Chr(94),)'^
t0=置換(t0,Chr(95),)'_
t0=置換(t0,Chr(96),)''
t0=置換(t0,Chr(123),)'{
t0=置換(t0,Chr(124),)'|
t0=置換(t0,Chr(125),)'}
t0=置換(t0,Chr(126),)'~
それ以外の場合
t0=置換(t0, &, &)
t0=置換(t0, ', ')
t0=置換(t0, , )
t0=置換(t0, <, <)
t0=置換(t0, >, >)
エンドセレクト
IF Instr(Lcase(t0),expression)>0 then
t0=置換(t0,式,式, 1, -1, 0)
終了の場合
フィルターテキスト=t0
終了機能
'======================================
'一般的な文字とHTMLをフィルタリングする
'======================================
関数 FilterHtml(ByVal t0)
IF Len(t0)=0 または IsNull(t0) または IsArray(t0) then FilterHtml=:Exit 関数
IF Len(Sdcms_Badhtml)>0 then t0=ReplaceText(t0,<(//|)(&Sdcms_Badhtml&), <$1$2)
IF Len(Sdcms_BadEvent)>0 then t0=ReplaceText(t0,<(.[^>]*)(&Sdcms_BadEvent&), <$1$2)
t0=フィルターテキスト(t0,0)
FilterHtml=t0
終了機能
関数 GotTopic(ByVal t0,ByVal t1)
Len(t0)=0 または IsNull(t0) の場合
ゴットトピック=
終了関数
終了IF
薄暗い l、t、c、i
t0=置換(置換(置換(置換(t0, , ),,chr(34)),>,>),<,<)
l=長さ(t0)
t=0
I=1 ~ l の場合
c=Abs(Asc(Mid(t0,i,1)))
IF c>255 then t=t+2 Else t=t+1
IF t>=t1 の場合
gotTopic=Left(t0,I)&…
出口
それ以外
GotTopic=t0
終了IF
次
GotTopic=Replace(Replace(Replace(Replace(GotTopic, , ),chr(34),),>,>),<,<)
終了機能
関数 URLDecode(ByVal t0)
ディム t1、t2、t3、i、t4、t5、t6
t1=
t2=偽
t3=
I=1 の場合 Len(t0)
t4=中間(t0,I,1)
IF t4=+ その後
t1=t1&
ElseIF t4=% then
t5=中間(t0,i+1,2)
t6=Cint(&H&t5)
IF t2 その後
t2=偽
t1=t1&Chr(Cint(&H&t3&t5))
それ以外
IF Abs(t6)<=127 then
t1=t1&Chr(t6)
それ以外
t2=真
t3=t5
終了IF
終了IF
I=I+2
それ以外
t1=t1&t4
終了IF
次
URLデコード=t1
終了機能
関数 CutStr(byVal t0,byVal t1)
薄暗い l、t、c、i
IF IsNull(t0) then CutStr=:Exit 関数
l=長さ(t0)
t1=Int(t1)
t=0
I=1 ~ l の場合
c=Asc(Mid(t0,I,1))
IF c<0 または c>255 then t=t+2 Else t=t+1
IF t>=t1 の場合
CutStr=Left(t0,I)&...
出口
それ以外
カットストラ=t0
終了IF
次
終了機能
関数 CloseHtml(ByVal t0)
ディム t1,I,t2,t3,Regs,Matches,J,Match
Regs=New RegExp を設定します
Regs.IgnoreCase=True
Regs.Global=True
t1=Array(p,div,span,table,ul,font,b,u,i,h1,h2,h3,h4,h5,h6)
I=0 から UBound(t1) の場合
t2=0
t3=0
Regs.Pattern=/<&t1(I)&( [^/</>]+|)/>
Set Matches=Regs.Execute(t0)
試合中の各試合について
t2=t2+1
次
Regs.Pattern=/</&t1(I)&/>
Set Matches=Regs.Execute(t0)
試合中の各試合について
t3=t3+1
次
j=1 の場合 t2-t3 まで
t0=t0+</&t1(I)&>
次
次
閉じるHTML=t0
終了機能