• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

filter out html tag in user input using validator

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, how can I filter out html tag in user input in validator?

I used the following code(this code actually is for the opposite case, say, true if the input has "<xxx>" substring. The reason is so far I don't know how to write the desired regular expression, "not-<xxx>"):

<var><var-name>mask</var-name><var-value>^<[^<>]+>$</var-value></var>

But the validator reports error, saying this is not well-formatted. I know the problem is "<" in "<[^<>]+>". I tried the unicode of "<", as the following, no error reported any more, but still not working(can't validate true if input has html tag:
<var><var-name>mask</var-name><var-value>^\u003c[^\u003c>]+>$</var-value></var>

Any one can help?

Thanks.
 
Ningfeng Xu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I solved this issue, as the following:

<![CDATA[ ^[^<]*[^>]*$ ]]>

This is not a strong solution, to detect html tags in user input, but so far good enough for me.
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic