473,487 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

strip jscript from user input

hello,

which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?

thanks in advance
george
P.S. the solution must allow users to enter html code.
Dec 17 '07 #1
6 1745
george wrote on 17 dec 2007 in comp.lang.javascript:
which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?
P.S. the solution must allow users to enter html code.
There is no "best way" in programming.
It depends on your prefeences.

Why would you strip script from an input?
Just make sure that it is never used in a html page.

Well, if you insist, use:

t = t.replace(/</g,'&lt;')

This is not stripping, but it won't be executed.

Why shouldn't you strip input values of script?

Because:

Someone's signature could be <script?

someone could input:

"if 7<a and href>7 then response.write c\"

You want to strip that?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 17 '07 #2
On Dec 17, 5:16 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
george wrote on 17 dec 2007 in comp.lang.javascript:
which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?
P.S. the solution must allow users to enter html code.

There is no "best way" in programming.
It depends on your prefeences.

Why would you strip script from an input?
Just make sure that it is never used in a html page.

Well, if you insist, use:

t = t.replace(/</g,'&lt;')

This is not stripping, but it won't be executed.

Why shouldn't you strip input values of script?

Because:

Someone's signature could be <script?

someone could input:

"if 7<a and href>7 then response.write c\"

You want to strip that?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
thanks for your reply

I just want the user to be able to post whatever he/she wants except
javascript/vbscript.
the replace solution " t.replace(/</g,'&lt;') " is not ideal, I don't
want code in the page.
this thing would be a personalization feature.

george
Dec 17 '07 #3
george wrote on 17 dec 2007 in comp.lang.javascript:
>Because:

Someone's signature could be <script?

someone could input:

"if 7<a and href>7 then response.write c\"

You want to strip that?
[Please do not quote signatures on usnet. Removed]
thanks for your reply

I just want the user to be able to post whatever he/she wants except
javascript/vbscript.
the replace solution " t.replace(/</g,'&lt;') " is not ideal, I don't
want code in the page.
this thing would be a personalization feature.
So if they include C++, Pascal or Java code, it is OK?

Some Javascript is also C++, some is not.

Or do you simply want to prevent clientside browser execution?

And plain old Basic source?

No I do not think your quest will have success.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 17 '07 #4
On Dec 17, 11:37 am, george <gparla...@gmail.comwrote:
On Dec 17, 5:16 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:


george wrote on 17 dec 2007 in comp.lang.javascript:
which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?
P.S. the solution must allow users to enter html code.
There is no "best way" in programming.
It depends on your prefeences.
Why would you strip script from an input?
Just make sure that it is never used in a html page.
Well, if you insist, use:
t = t.replace(/</g,'&lt;')
This is not stripping, but it won't be executed.
Why shouldn't you strip input values of script?
Because:
Someone's signature could be <script?
someone could input:
"if 7<a and href>7 then response.write c\"
You want to strip that?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

thanks for your reply

I just want the user to be able to post whatever he/she wants except
javascript/vbscript.
the replace solution " t.replace(/</g,'&lt;') " is not ideal, I don't
want code in the page.
this thing would be a personalization feature.

george- Hide quoted text -

- Show quoted text -
Could you instead just allow only certain html tags? Otherwise, I
think it is going to be difficult to filter out any type of scripting.

If you check for say, "<script>" javascript could still be put in
elements and triggered by events, like <input type="button"
onclick="function getCHA(){alert('do bad stuff here')} getCHA()"
value="click me" />

If you allow PHP and the page is PHP, then they could pretty much do
all kind of stuff.
Dec 17 '07 #5
george said the following on 12/17/2007 12:37 PM:

<snip>
thanks for your reply

I just want the user to be able to post whatever he/she wants except
javascript/vbscript.
the replace solution " t.replace(/</g,'&lt;') " is not ideal, I don't
want code in the page.
this thing would be a personalization feature.
Whatever you do, you are going to have to duplicate it on the server
anyway. What is to stop the user from disabling script, or, bypassing
your validation?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 17 '07 #6
On Dec 17, 6:57 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
george said the following on 12/17/2007 12:37 PM:

<snip>
thanks for your reply
I just want the user to be able to post whatever he/she wants except
javascript/vbscript.
the replace solution " t.replace(/</g,'&lt;') " is not ideal, I don't
want code in the page.
this thing would be a personalization feature.

Whatever you do, you are going to have to duplicate it on the server
anyway. What is to stop the user from disabling script, or, bypassing
your validation?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
thanks guys for your replies

I know it's not the easiest thing to do properly.
What we need is to allow html/flash stuff but not scripts that browser
could execute.

regards,
george
Dec 18 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2804
by: | last post by:
Could some help m figure out to strip an unknown range of characters in a path between the first "/" and "/" found in a folder path somewhere on my site. eg: /catamaranco/sales/boat/1.asp eg:...
1
4437
by: Pino Carafa | last post by:
I've designed an aspx page with a Tab Strip on it. The problem is that unlike some of the simpler controls like text boxes and buttons and the likes, this Tab Strip is rendered something like this:...
6
2134
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows...
1
1282
by: Chuck Traywick | last post by:
Finally getting some thing to work but am perlpexed by client side jScript code. Two questions we'd really appreciate some feedback on: 1: If we have a function in JScript that validates a...
3
1584
by: Larry David | last post by:
Hi, I'm just trying to wrap my mind around the ASP.NET model. Let me walk you through a trivial scenario: Let's say I have a form containing a text box where the user enters his name. It also...
1
4198
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>...
2
3354
by: Cruella DeVille | last post by:
I must have som errors in my understanding of strip- vs addslashes. I thought that if a user submitted eg a username, like this username=siv' drop database test; I should addslashes to escape ' and...
5
1905
by: steve9013 | last post by:
Hello. Hoping someone can help me out with this. Please forgive me as I'm very new to jscript. I need to have the input box at the top of the page store the string to a variable. I then need...
4
1659
by: Ajvan | last post by:
Hi everybody, I have one problem, and I hope some of you guys can help me with this. I`m working in C# (Visual Studio 2005)...writing simple web site . I place grid on Default.aspx and put one...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.