ASP Question

J

John Davis

What is this function attempting to do? Please advice. Thanks!

Function UnknownFunction(x)
If InStr(x, "http://")=0 Then
vx = x
Else
vx = Replace(x,"http://","")
End If
vAD = "1234567890qwertyuiopasdfghjklzxcvbnm_./"
UnknownFunction = True
For I=1 to Len(vx)
Symbol = Mid(vx,I,1)
If InStr(1,vAD, Symbol, 0) = 0 Then UnknownFunction = False
Next
End Function
 
E

Evertjan.

John Davis wrote on 17 aug 2003 in
microsoft.public.inetserver.asp.general:
What is this function attempting to do? Please advice. Thanks!

Function UnknownFunction(x)
If InStr(x, "http://")=0 Then
vx = x
Else
vx = Replace(x,"http://","")
End If
vAD = "1234567890qwertyuiopasdfghjklzxcvbnm_./"
UnknownFunction = True
For I=1 to Len(vx)
Symbol = Mid(vx,I,1)
If InStr(1,vAD, Symbol, 0) = 0 Then UnknownFunction = False
Next
End Function

The function returns true if the parameter with a possible "http://"
stripped off, has NO characters that are NOT in the string specified by
the variable vAD

Mind that a string with a capital, like: "http://www.CNN.com" or even:
"HTTP://www.cnn.com" will also let the function return false !!

========================================

The function is needlessly long and timeconsuming.

I would write the function like this:

Function UnknownFunction(x)
x = Replace(x,"http://","")
Set regEx = New RegExp
regEx.Pattern = "[^\da-z_\.\/]"
UnknownFunction = not regEx.Test(x)
End Function

Tested
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,589
Members
47,211
Latest member
JaydenBail

Latest Threads

Top