2017-10-07 7 views
0

login.aspの検証ページを呼び出すlogin_form.aspから格納された入力(ユーザー名とパスワード)を比較しようとしています。私は、正規表現の条件を除いて動作するコードを持っています。移動する前にifステートメントを追加して条件を比較すると、ページがクラッシュします。私は、接続の試行前にa-z0-9入力を許可したいだけです。 if条件をコメントアウトすると、フォームの検証は機能しますが、正規表現は機能しません。これはASP Classicです。任意の洞察力や助けに感謝します。ここでregex vbscriptでユーザー入力を消毒しようとしました

は、私が働いているコードです:

dim userName, password, query 
dim conn, rs 
Dim reg 
Set reg = new RegExp 
reg.Pattern = "[a-z0-9] + @[a-z0-9\.] +" 

userName = Request.Form("userName") 
password = Request.Form("password") 

response.write userName & "<P>" 

if reg.Test("userName") then 
response.write "regex userName = true" 
endif 

if reg.Test("password") then 
response.write "regex password = true" 
endif 

set conn = server.createObject("ADODB.Connection") 
set rs = server.createObject("ADODB.Recordset") 

query = "select UserName from users where userName='" & userName & "' 
and  userPass='" & password & "'" 
response.write query & "<P>" 

答えて

0

ではなく

regex.test( "ユーザ名")

regext.test(ユーザー名)

を試してみてください

2番目の変数は、変数ではなく文字列リテラル "username"を実行します。 regex.test()

あなたの正規表現パターンも奇妙に見えます。

regexlib.comは...正規表現の検索可能な選択をしてい

そして最後に、あなたは、データベースクエリを実行し、あなたのアプローチを再考することがあります。あなたはそれをやっているどのようにSQLインジェクション攻撃にオープンです。 adoにはParametersオブジェクトを使用します。

関連する問題