Re: How can I allow certain HTML tags within a textarea?
- From: "Gabriella" <frohlinger@xxxxxxxxx>
- Date: 8 Feb 2007 00:33:45 -0800
On Feb 6, 4:17 pm, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
Replied to [Gabriella]s message :
Hi,
I have a website (http://www.grazeit.com), where users can post notes
with free text.
I would like to allow users SOME HTML tags in the textarea (not all
HTML tags because otherwise I'll be exposed to XSS and other tricks).
I would like to allow only the following tags:
'a' => 'href', 'target'
'b' => None
'blockquote' => None
'em' => None
'i' => None
'img' => 'src', 'width', 'height', 'alt', 'title' (of course, without
window.location, javascript:, etc... but only "http://www..." and
would also like to limit the values of width and height)
'strong' => None
'u' => None
How do I check it (on server-side of course)?
With Regular Expression? Can you show me how?
This will tell you about all the valid tags in textarea with id txtA then you can do
whatever you want with it.
Sub testRx
set rXp = New RegExp
rXp.IgnoreCase = 1 : rXp.Global=1
ok = true
tagss=""
rXp.Pattern = "<\s*(\w).*?>(?=[\s\S]*</\1\s*>)"
set tags = rXp.Execute(txtA.innerText)
For Each tag in tags
tagss = tagss & tag & vbCr
Next
msgbox tagss
End Sub
Good Luck, Ayush.
--
XP-Tips [Auto logon for Windows XP] :http://www.microsoft.com/windowsxp/using/setup/tips/advanced/autologo...
Hi,
Thanks for the sub, but I still have trouble with it.
First, I think that it does not fetch all the HTML tags in my
textarea.
Second, the "tag" variable returns the entire tag, e.g.: <a
href="...">something</a> and I still have to parse it to find out
which tag it is (is it from my allowed-tags list or not), as well as
check the attributes of the tag (e.g.: <img src="javascript:..."> is
not allowed).
Any ideas?
Thanks again, Gabi
This sub does only part of the work.
.
- Follow-Ups:
- References:
- How can I allow certain HTML tags within a textarea?
- From: Gabriella
- Re: How can I allow certain HTML tags within a textarea?
- From: Ayush
- How can I allow certain HTML tags within a textarea?
- Prev by Date: Re: er, um, wrong again...
- Next by Date: Re: How can I allow certain HTML tags within a textarea?
- Previous by thread: Re: How can I allow certain HTML tags within a textarea?
- Next by thread: Re: How can I allow certain HTML tags within a textarea?
- Index(es):
Relevant Pages
|