|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我想详细了解ASP整站代码与PSP整站代码有什么优缺点,那个更好,更安全,更用容易维护,和管理。。。平安|数据|数据库|显现 好比说有styledesc这个字段,数据请求的是50位,char形,可不成以只限定他50位,别的的不限定,输出甚么字符都能够的.只需是char形,只需数据库同意就行
如许,平安写进数据库操纵,一般读出并显现在分歧的场所,使用.
应当是如何做呢?
上面是我总结的几点.十分有大概不合错误,请斧正.
假如对用户的输出是能够恣意字符,(除某字段特定的输出限定前提,如输出长度,输出范例==).就是输出尽量不作限定.
对一字符串str,他输入的偏向有以下几种:
1.输入至HTML中,Functionfn_chk_to_html(Str)
2.输入至Script中(如javascript),Functionfn_chk_to_script(Str)
3.输入至sql语句中,并且这条SQL语句是用两个单引括起字符串Str的.
Functionfn_chk_to_sql_mark(Str)
4.输入至sql语句中,并且这条SQL语句是没有效单引括起Str的.Functionfn_chk_to_sql_go(Str)
5.输入至URL.Functionfn_chk_to_url(Str)
<%Functionfn_chk_to_html(Str)
如<inputtext="<%=request("styledesc")%>">的情形下
IfIsnull(Str)Then
ChkSql=""
ExitFunction
EndIf
Str=trim(Str)
Str=Replace(Str,Chr(0),"",1,-1,1)
Str=Replace(Str,"""",""",1,-1,1)
Str=Replace(Str,"","",1,-1,1)
Str=Replace(Str,"<","<",1,-1,1)
Str=Replace(Str,">",">",1,-1,1)
Str=Replace(Str,vbCrlf,"<br>",1,-1,1)
fn_chk_to_html=Str
EndFunction
%>
<%Functionfn_chk_to_script(Str)
如response.write"<script>alert("&request("styledesc")&");</script>"的情形下
IfIsnull(Str)Then
ChkSql=""
ExitFunction
EndIf
Str=trim(Str)
Str=Replace(Str,"","",1,-1,1)
Str=Replace(Str,"""","""",1,-1,1)
Str=Replace(Str,"","",1,-1,1)
Str=Replace(Str,Chr(13),"
",1,-1,1)
fn_chk_to_script=Str
EndFunction
%>
<%
Functionfn_chk_to_sql_mark(Str)
如sql="select*fromstylewherestyledesclike"&request("styledesc")&""的情形下
IfIsnull(Str)Then
ChkSql=""
ExitFunction
EndIf
Str=trim(Str)
Str=Replace(Str,"","",1,-1,1)
fn_chk_to_sql_mark=Str
EndFunction
%>
<%Functionfn_chk_to_sql_go(Str)
如sql="select*from"&request("table")的情形下.??
IfIsnull(Str)Then
ChkSql=""
ExitFunction
EndIf
Str=trim(Str)
Str=Replace(Str,Chr(0),"",1,-1,1)
Str=Replace(Str,"""",""",1,-1,1)
Str=Replace(Str,"","",1,-1,1)
Str=Replace(Str,"<","<",1,-1,1)
Str=Replace(Str,">",">",1,-1,1)
Str=Replace(Str,"[","[",1,-1,1)
Str=Replace(Str,"]","]",1,-1,1)
Str=Replace(Str,"","\",1,-1,1)
Str=Replace(Str,"*","*",1,-1,1)
Str=Replace(Str,"%","%",1,-1,1)
Str=Replace(Str,";",";",1,-1,1)
Str=Replace(Str,vbCrlf,"<br>",1,-1,1)
Str=Replace(Str,"--","--")
fn_chk_to_sql_go=Str
EndFunction
%>
<%Functionfn_chk_to_url(Str)
如str="<imgsrc=showimg.asp?id="&request("id")&">"的情形下
IfIsnull(Str)Then
ChkSql=""
ExitFunction
EndIf
Str=trim(Str)
Str=server.URLEncode(Str)
fn_chk_to_sql_mark=Str
EndFunction
%>
想法是和程序员的想法不一样的.至于为什么.大家去想一想.跟心理学有关的 |
|