需要防弹输入验证器 [英] need bullet proof input validator

查看:67
本文介绍了需要防弹输入验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨人。我试图验证通过ASP

页面上的文本区域收到的输入,然后再将其写入数据库。我不能使用客户端javascript到期/ b $ b到策略,所以这一切都必须在服务器上进行。这就是我正在尝试的,

但是由于某种原因,它的碎片继续破裂。这个函数背后的思考

是这样的:


如果输入长度小于10个字符,则失败。

if它的10个字符或更大,但它似乎不包含任何单词,

失败。 (我通过将空格字符的输入分解为

数组来尝试这个。有效输入应该有几个空格,表示几个单词)

如果有3个连续的空格,失败。 (这不能有效)。

然后如果所有通过,我需要确保没有单词超过10

个字符。 (通过遍历数组中的单词)


不同的部分在不同的时间失败。例如,如果数据

有换行符,则会失败(不知道为什么。换行符被视为3个空格?)

因为此处有太多移动部件我希望其他人可能会有更好的方法验证输入。

感谢您的帮助。

函数IsGoodInput(str)< br $>
IsGoodInput = True

Dim MyArray,i

MyArray = Split(str,"")

如果Len(str)< 10或InStr(str,"")< 0或UBound(MyArray)= 0然后

IsGoodInput = False

否则

对于i = 0到UBound(MyArray)

如果Len(MyArray(i))10那么

IsGoodInput = False

退出

结束如果

下一页

结束如果

结束功能

hi people. im trying to validate input received via a text area on an ASP
page before writing it to a database. i cant use client side javascript due
to policy, so it all has to happen on the server. here is what i was trying,
but pieces of it continue to break for one reason or another. the thinking
behind this function was like this:

if the input is less than 10 characters long, fail.
if its 10 characters or greater, but it doesnt appear to contain any words,
fail. (i try this by breaking up the input at space characters into an
array. valid input should have several spaces, indicating several words)
if there are 3 consecutive spaces, fail. (this cant be valid).
then if all that passes, i need to make sure no words are longer than 10
characters. (by looping through the words in the array)

different parts of this fail at different times. for instance if the data
has a newline, it fails (not sure why. is a newline looked at as 3 spaces?)
since there are too many moving parts here i was hoping someone else might
have a better approach to validating the input.
thanks for any help.
Function IsGoodInput(str)
IsGoodInput = True
Dim MyArray, i
MyArray = Split(str, " ")
If Len(str) < 10 Or InStr(str, " ") <0 Or UBound(MyArray) = 0 Then
IsGoodInput = False
Else
For i = 0 To UBound(MyArray)
If Len(MyArray(i)) 10 Then
IsGoodInput = False
Exit For
End If
Next
End If
End Function

推荐答案



SLH写道:

SLH wrote:

hi people。我试图验证通过ASP

页面上的文本区域收到的输入,然后再将其写入数据库。我不能使用客户端javascript到期/ b $ b到策略,所以这一切都必须在服务器上进行。这就是我正在尝试的,

但是由于某种原因,它的碎片继续破裂。这个函数背后的思考

是这样的:


如果输入长度小于10个字符,则失败。

if它的10个字符或更大,但它似乎不包含任何单词,

失败。 (我通过将空格字符的输入分解为

数组来尝试这个。有效输入应该有几个空格,表示几个单词)

如果有3个连续的空格,失败。 (这不能有效)。

然后如果所有通过,我需要确保没有单词超过10

个字符。 (通过遍历数组中的单词)


不同的部分在不同的时间失败。例如,如果数据

有换行符,则会失败(不知道为什么。换行符被视为3个空格?)

因为此处有太多移动部件我希望其他人可能会有更好的方法验证输入。

感谢任何帮助。
hi people. im trying to validate input received via a text area on an ASP
page before writing it to a database. i cant use client side javascript due
to policy, so it all has to happen on the server. here is what i was trying,
but pieces of it continue to break for one reason or another. the thinking
behind this function was like this:

if the input is less than 10 characters long, fail.
if its 10 characters or greater, but it doesnt appear to contain any words,
fail. (i try this by breaking up the input at space characters into an
array. valid input should have several spaces, indicating several words)
if there are 3 consecutive spaces, fail. (this cant be valid).
then if all that passes, i need to make sure no words are longer than 10
characters. (by looping through the words in the array)

different parts of this fail at different times. for instance if the data
has a newline, it fails (not sure why. is a newline looked at as 3 spaces?)
since there are too many moving parts here i was hoping someone else might
have a better approach to validating the input.
thanks for any help.



使用正则表达式。

Use regular expressions.




" Larry芽" < la ********** @ yahoo.comwrote in message

news:11 ******************** **@m7g2000cwm.googlegro ups.com ...

"Larry Bud" <la**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...

>

SLH写道:
>
SLH wrote:

>嗨人。我试图验证通过ASP
页面上的文本区域收到的输入,然后再将其写入数据库。我不能使用客户端javascript
到政策,所以这一切都必须发生在服务器上。这就是我在尝试的事情,
但是它的一些因为某种原因而继续破裂。这个函数背后的思考是这样的:

如果输入长度少于10个字符,则失败。
如果它的10个字符或更大,但它似乎不包含任何单词,
失败。 (我通过将空格字符的输入分解为
数组来尝试这个。有效输入应该有几个空格,表示几个单词)
如果有3个连续的空格,则失败。 (这不能有效)。
然后如果一切都过去了,我需要确保没有任何单词超过10个字符。 (通过循环遍历数组中的单词)

此不同部分在不同时间失败。例如,如果数据有一个换行符,它就会失败(不知道为什么。换行符被视为3个空格?)
因为这里有太多的移动部件我希望有人否则
可能会有更好的方法来验证输入。
感谢您的帮助。
>hi people. im trying to validate input received via a text area on an ASP
page before writing it to a database. i cant use client side javascript
due
to policy, so it all has to happen on the server. here is what i was
trying,
but pieces of it continue to break for one reason or another. the
thinking
behind this function was like this:

if the input is less than 10 characters long, fail.
if its 10 characters or greater, but it doesnt appear to contain any
words,
fail. (i try this by breaking up the input at space characters into an
array. valid input should have several spaces, indicating several words)
if there are 3 consecutive spaces, fail. (this cant be valid).
then if all that passes, i need to make sure no words are longer than 10
characters. (by looping through the words in the array)

different parts of this fail at different times. for instance if the data
has a newline, it fails (not sure why. is a newline looked at as 3
spaces?)
since there are too many moving parts here i was hoping someone else
might
have a better approach to validating the input.
thanks for any help.



使用正则表达式。


Use regular expressions.



谢谢,听起来不错。我有点希望得到帮助。也许是一个好榜样的形式

?正则表达式不是我的强项。

thanks, sounds great. i was kinda hoping for help though. maybe in the form
of a good example? regular expressions arent exactly my strong point.


SLH于2006年10月2日在microsoft.public.inetserver.asp.general写道:
SLH wrote on 02 Oct 2006 in microsoft.public.inetserver.asp.general:

>使用正则表达式。
>Use regular expressions.



谢谢,听起来不错。我有点希望得到帮助。也许在

形式的一个很好的例子?正则表达式并不完全是我强烈的

点。


thanks, sounds great. i was kinda hoping for help though. maybe in the
form of a good example? regular expressions arent exactly my strong
point.



我们都必须学习。

最好的帮助是如果你开始,我们一起去。


-

Evertjan。

荷兰。

(请将我的电子邮件地址中的x'变为点数)

We all had to learn.
Ther best help is if you start of, and we go along.

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


这篇关于需要防弹输入验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆