![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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,'<') 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) |
#4
| |||
| |||
|
|
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? |
|
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,'<') " is not ideal, I don't want code in the page. this thing would be a personalization feature. |
#5
| |||
| |||
|
|
On Dec 17, 5:16 pm, "Evertjan." <exjxw.hannivo... (AT) interxnl (DOT) net> wrote: 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,'<') 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,'<') " 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 - |
#6
| |||
| |||
|
|
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,'<') " is not ideal, I don't want code in the page. this thing would be a personalization feature. |
#7
| |||
| |||
|
|
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,'<') " 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/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |