Ik heb een tekstbalk waar gebruikers berichten kunnen toevoegen (url zie signature) en ik heb een script geschreven om html-code, volledige lege velden en dubbel invoer tegen te gaan.
Alleen als de gebruiker 1 of meer spaties invoert en het toevoegt dan wordt het dus wel toegevoegd. Hoe kan je dit tegengaan in ASP?
Huidige code om html tegen te gaan:
strHtml = Request.form("msg")
'Strips the HTML tags from strHTML using split and join
'Ensure that strHTML contains something
If len(strHTML) = 0 then
stripHTML = strHTML
End If
dim arysplit, i, j, strOutput
arysplit = split(strHTML, "<")
'Assuming strHTML is nonempty, we want to start iterating
'from the 2nd array postition
if len(arysplit(0)) > 0 then j = 1 else j = 0
'Loop through each instance of the array
for i=j to ubound(arysplit)
'Do we find a matching > sign?
if instr(arysplit(i), ">") then
'If so, snip out all the text between the start of the string
'and the > sign
arysplit(i) = mid(arysplit(i), instr(arysplit(i), ">") + 1)
else
'Ah, the < was was nonmatching
arysplit(i) = "<" & arysplit(i)
end if
next
'Rejoin the array into a single string
strOutput = join(arysplit, "")
'Snip out the first <
strOutput = mid(strOutput, 2-j)
stripHTML = strOutput
Alleen als de gebruiker 1 of meer spaties invoert en het toevoegt dan wordt het dus wel toegevoegd. Hoe kan je dit tegengaan in ASP?
Huidige code om html tegen te gaan:
strHtml = Request.form("msg")
'Strips the HTML tags from strHTML using split and join
'Ensure that strHTML contains something
If len(strHTML) = 0 then
stripHTML = strHTML
End If
dim arysplit, i, j, strOutput
arysplit = split(strHTML, "<")
'Assuming strHTML is nonempty, we want to start iterating
'from the 2nd array postition
if len(arysplit(0)) > 0 then j = 1 else j = 0
'Loop through each instance of the array
for i=j to ubound(arysplit)
'Do we find a matching > sign?
if instr(arysplit(i), ">") then
'If so, snip out all the text between the start of the string
'and the > sign
arysplit(i) = mid(arysplit(i), instr(arysplit(i), ">") + 1)
else
'Ah, the < was was nonmatching
arysplit(i) = "<" & arysplit(i)
end if
next
'Rejoin the array into a single string
strOutput = join(arysplit, "")
'Snip out the first <
strOutput = mid(strOutput, 2-j)
stripHTML = strOutput