Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validating user HTML input

Reply
Thread Tools

Validating user HTML input

 
 
Peter Morris [Air Software Ltd]
Guest
Posts: n/a
 
      01-02-2005
Hi all

I want to allow users to enter HTML, but I want to ensure that

A) The HTML entered only contains a subset of html tags (a, img, div, etc)
and not certain other elements (html, body, script) etc.

B) The HTML is syntactically correct, so a <li> would have a corresponding
</li>, a <td> would have a </td>, etc.

I'm pretty confident that .net already has something to do this, but I have
no clue what. Can anyone help?

Thanks


--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


 
Reply With Quote
 
 
 
 
Greg Burns
Guest
Posts: n/a
 
      01-02-2005
Regular expressions can do this sort of thing. That's where I would be
investigating.

Greg

"Peter Morris [Air Software Ltd]" <> wrote in
message news:%...
> Hi all
>
> I want to allow users to enter HTML, but I want to ensure that
>
> A) The HTML entered only contains a subset of html tags (a, img, div, etc)
> and not certain other elements (html, body, script) etc.
>
> B) The HTML is syntactically correct, so a <li> would have a corresponding
> </li>, a <td> would have a </td>, etc.
>
> I'm pretty confident that .net already has something to do this, but I
> have no clue what. Can anyone help?
>
> Thanks
>
>
> --
> Pete
> ====
> Read or write articles on just about anything
> http://www.HowToDoThings.com
>
> My blog
> http://blogs.slcdug.org/petermorris/
>



 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-02-2005


Peter Morris [Air Software Ltd] wrote:


> I want to allow users to enter HTML, but I want to ensure that


> B) The HTML is syntactically correct, so a <li> would have a corresponding
> </li>, a <td> would have a </td>, etc.


According to
<http://www.w3.org/TR/html4/struct/lists.html>
the closing </li> is optional, and according to
<http://www.w3.org/TR/html4/struct/tables.html>
the closing </td> is optional too so a HTML syntax checker would be
wrong to complain about missing closng </li> or </td> tags.

As for HTML syntax checking with .NET perhaps Tidy can help with that:
<http://users.rcn.com/creitzel/tidy.html#dotnet>
I am not sure however it will help if you only want to allow a subset of
HTML but maybe you can write a custom DTD and have Tidy use that.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Peter Morris [Air Software Ltd]
Guest
Posts: n/a
 
      01-02-2005
Hi

It seems a bit too complicated for RegEx to me (or for me in RegEx). Not
only would I want to prevent <script> inserts, validate the input etc, but
also prevent javascript being inserted as a click event or something as a
parameter to some html.

What do you think?


--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


 
Reply With Quote
 
Peter Blum
Guest
Posts: n/a
 
      01-03-2005
Hi Peter,

I wrote a commercial product that specifically addresses this. Visual Input
Security (http://www.peterblum.com/vise/home.aspx) provides new validators
that handle SQL injection and Script injection attacks. The validators look
at all inputs: visible controls, hidden fields, query strings, and cookies.
They look for illegal tags, tags you just want to avoid, and embedded
javascript in legal tags. They log errors and notify you via email. They can
block access to a page after the hacker makes several attempts.

--- Peter Blum
www.PeterBlum.com
Email:
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Peter Morris [Air Software Ltd]" <> wrote in
message news:...
> Hi
>
> It seems a bit too complicated for RegEx to me (or for me in RegEx). Not
> only would I want to prevent <script> inserts, validate the input etc, but
> also prevent javascript being inserted as a click event or something as a
> parameter to some html.
>
> What do you think?
>
>
> --
> Pete
> ====
> Audio compression components, DIB graphics controls, FastStrings
> http://www.droopyeyes.com
>
> Read or write articles on just about anything
> http://www.HowToDoThings.com
>
> My blog
> http://blogs.slcdug.org/petermorris/
>



 
Reply With Quote
 
Peter Morris [Air Software Ltd]
Guest
Posts: n/a
 
      01-09-2005
Hi

Do you have an online demo? I don't like to download anything ASPX related
unless I have already tried it online and decided that it looks like
something I want.

Thanks


--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User input date Validating Tamer Ibrahim ASP .Net 1 11-12-2007 01:16 PM
any other idea of validating user input except regular expressions Oliver Bleckmann C++ 1 12-01-2006 04:32 AM
Validating user input? chuck C Programming 9 06-07-2006 08:30 PM
Validating User Input (numeric only, and valid email address attributes) charleswesley@gmail.com ASP .Net 2 10-01-2005 07:49 PM
validating user form input with vs.net/vb.net front end and backend darrel ASP .Net 1 06-24-2004 10:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57