Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/10/2010, 13:30
Avatar de lexus
lexus
 
Fecha de Ingreso: enero-2002
Ubicación: Cali - Colombia
Mensajes: 2.234
Antigüedad: 22 años, 4 meses
Puntos: 4
Respuesta: impedir codigos maliciosos en formularios.

hola
ya lo encontre buscando en las funciones de este foro de todas maneras muchas gracias

aqui lo publico.


Código ASP:
Ver original
  1. Function RemoveHTML(strText)
  2.     Dim TAGLIST
  3.     TAGLIST = ";!--;!DOCTYPE;A;ACRONYM;ADDRESS;APPLET;AREA;B;BASE;BASEFONT;" &_
  4.               "BGSOUND;BIG;BLOCKQUOTE;BODY;BR;BUTTON;CAPTION;CENTER;CITE;CODE;" &_
  5.               "COL;COLGROUP;COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT;EM;EMBED;FIELDSET;" &_
  6.               "FONT;FORM;FRAME;FRAMESET;HEAD;H1;H2;H3;H4;H5;H6;HR;HTML;I;IFRAME;" &_
  7.               "INPUT;INS;ISINDEX;KBD;LABEL;LAYER;LAGEND;LI;LINK;LISTING;MAP;MARQUEE;" &_
  8.               "MENU;META;NOBR;NOFRAMES;NOSCRIPT;OBJECT;OL;OPTION;PARAM;PLAINTEXT;" &_
  9.               "PRE;Q;S;SAMP;SCRIPT;SELECT;SMALL;SPAN;STRIKE;STRONG;STYLE;SUB;SUP;" &_
  10.               "TABLE;TBODY;TD;TEXTAREA;TFOOT;TH;THEAD;TITLE;TR;TT;U;UL;VAR;WBR;XMP;"
  11.  
  12.     Const BLOCKTAGLIST = ";APPLET;EMBED;FRAMESET;HEAD;NOFRAMES;NOSCRIPT;OBJECT;SCRIPT;STYLE;"
  13.    
  14.     Dim nPos1
  15.     Dim nPos2
  16.     Dim nPos3
  17.     Dim strResult
  18.     Dim strTagName
  19.     Dim bRemove
  20.     Dim bSearchForBlock
  21.    
  22.     nPos1 = InStr(strText, "<")
  23.     Do While nPos1 > 0
  24.         nPos2 = InStr(nPos1 + 1, strText, ">")
  25.         If nPos2 > 0 Then
  26.             strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
  27.         strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")
  28.  
  29.             nPos3 = InStr(strTagName, " ")
  30.             If nPos3 > 0 Then
  31.                 strTagName = Left(strTagName, nPos3 - 1)
  32.             End If
  33.            
  34.             If Left(strTagName, 1) = "/" Then
  35.                 strTagName = Mid(strTagName, 2)
  36.                 bSearchForBlock = False
  37.             Else
  38.                 bSearchForBlock = True
  39.             End If
  40.            
  41.             If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  42.                 bRemove = True
  43.                 If bSearchForBlock Then
  44.                     If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
  45.                         nPos2 = Len(strText)
  46.                         nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare)
  47.                         If nPos3 > 0 Then
  48.                             nPos3 = InStr(nPos3 + 1, strText, ">")
  49.                         End If
  50.                        
  51.                         If nPos3 > 0 Then
  52.                             nPos2 = nPos3
  53.                         End If
  54.                     End If
  55.                 End If
  56.             Else
  57.                 bRemove = False
  58.             End If
  59.            
  60.             If bRemove Then
  61.                 strResult = strResult & Left(strText, nPos1 - 1)
  62.                 strText = Mid(strText, nPos2 + 1)
  63.             Else
  64.                 strResult = strResult & Left(strText, nPos1)
  65.                 strText = Mid(strText, nPos1 + 1)
  66.             End If
  67.         Else
  68.             strResult = strResult & strText
  69.             strText = ""
  70.         End If
  71.        
  72.         nPos1 = InStr(strText, "<")
  73.     Loop
  74.     strResult = strResult & strText
  75.    
  76.     RemoveHTML = strResult
  77. End Function
__________________
Control de Visitantes, Control de Accesos, Minutas digitales, Manejo de Correspondencia
http://www.controldevisitantes.com