This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED] Replacing/Ignoring bad characters in code

Help for those learning Tcl or writing their own scripts.
Post Reply
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

[SOLVED] Replacing/Ignoring bad characters in code

Post by vigilant »

How can I accomplish this?
Lets say the nickname has a character such as \
how can I get rid of it or ignore it?

please suggest :)
Last edited by vigilant on Tue Dec 09, 2008 1:59 pm, edited 1 time in total.
Anser Quraishi
Website: http://www.anserq.com
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

What "bad" characters? Are you sure you want to ignore them? Here's a line that will get rid of alot of characters:

Code: Select all

regsub -all \\W+ $string "" string
...but I'm not sure this is what you really need :wink: (your wording makes me think you might be having problems related to treating strings as lists)
Have you ever read "The Manual"?
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Post by vigilant »

user wrote:What "bad" characters? Are you sure you want to ignore them? Here's a line that will get rid of alot of characters:

Code: Select all

regsub -all \\W+ $string "" string
...but I'm not sure this is what you really need :wink: (your wording makes me think you might be having problems related to treating strings as lists)
Yes , hello for your prompt reply. I guess so, like first when you receive the nickname argument using a normal bind... and it has characters like, \ / [] and so on. What's the easiest way to capture the nickname including the [ ] , because it's not when it has \ / characters...
Anser Quraishi
Website: http://www.anserq.com
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It sounds to me like you are looking for ways to avoid being exploited by nicknames such as [die].

The proper way of avoiding this is not to do massive regexp's, and other mangling, but rather use proper tcl-scripting, being aware of the command and variable substitutions done by the tcl engine, and when it does this.
This, of course, isn't something can can expect from a fresh tcl-coder, but comes from experience. If you post examples of where you are having problems, we could better point you in the right way in those specific issues.

One "rule of thumb" however, if you need to build a command line to be passed to the tcl interpreter (such as when you use timer/utimer), make it a list, as this will protect the individual items from substitutions during the next parsing.
NML_375
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Post by vigilant »

nml375 wrote:It sounds to me like you are looking for ways to avoid being exploited by nicknames such as [die].

The proper way of avoiding this is not to do massive regexp's, and other mangling, but rather use proper tcl-scripting, being aware of the command and variable substitutions done by the tcl engine, and when it does this.
This, of course, isn't something can can expect from a fresh tcl-coder, but comes from experience. If you post examples of where you are having problems, we could better point you in the right way in those specific issues.

One "rule of thumb" however, if you need to build a command line to be passed to the tcl interpreter (such as when you use timer/utimer), make it a list, as this will protect the individual items from substitutions during the next parsing.
Okay.. thanks. I was thinking of list :) Thanks for clarifying.
Anser Quraishi
Website: http://www.anserq.com
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Post by vigilant »

Sir_Fz wrote:Script Security
I think better than that is, http://www.peterre.info/characters.html
Anser Quraishi
Website: http://www.anserq.com
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That is mentioned in the "Script Security" thread vigilant :)
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Post by vigilant »

Sir_Fz wrote:That is mentioned in the "Script Security" thread vigilant :)
lolllllllll :) Well great then :O
Anser Quraishi
Website: http://www.anserq.com
Post Reply