I have some code that checks input values before I insert it into the db. And it works as it should, it checks all form inputs, but I would like it to exclude all the file upload inputs, so it doesn´t check the values of file inputs when I upload an image. But I don´t know how to make it work, so any input really appreciated. Thanks.
This is what I have now.
Dim BlackList, ErrorPage
BlackList = Array("#","$","%","^","&","|",_
"<",">","'","""","(",")",_
"--", "/*", "*/", "@@",_
"cursor","exec","execute",_
"nchar", "varchar", "nvarchar", "iframe", "char", "alter", "begin", "cast", "create", "insert","delete", "drop", "table"_
)
Function CheckStringForSQL(str,varType)
On Error Resume Next
Dim lstr
' If the string is empty, return false that means pass
If ( IsEmpty(str) ) Then
CheckStringForSQL = false
Exit Function
ElseIf ( StrComp(str, "") = 0 ) Then
CheckStringForSQL = false
Exit Function
End If
lstr = LCase(str)
' Check if the string contains any patterns in our black list
For Each s in BlackList
If(IsExceptionList(s,varType)=False) then
If ( InStr (lstr, s) <> 0 ) Then
CheckStringForSQL = true
Exit Function
End If
End If
Next
CheckStringForSQL = false
End Function
CookieExceptionList = Array("""","(",")","!")
Function IsExceptionList(str,varType)
If(varType="cookie") then
For Each item in CookieExceptionList
If(item=str) then
IsExceptionList=True
Exit Function
End If
Next
End If
IsExceptionList=False
End Function
--SO HERE I NEED TO CHECK IF IT IS A FILE INPUT, AND IF SO, NOT RUN THE BELOW--
For Each s in Request.form
If ( CheckStringForSQL(Request.form(s),"form") ) Then
feltext="Fel"
End If
Next