| View previous topic :: View next topic |
| Author |
Message |
vigilant Halfop
Joined: 05 Jan 2006 Posts: 48
|
Posted: Mon Dec 08, 2008 9:39 pm Post subject: [SOLVED] Replacing/Ignoring bad characters in code |
|
|
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  _________________ Anser Quraishi
Website: http://www.anserq.com
Last edited by vigilant on Tue Dec 09, 2008 1:59 pm; edited 1 time in total |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Dec 09, 2008 5:39 am Post subject: |
|
|
What "bad" characters? Are you sure you want to ignore them? Here's a line that will get rid of alot of characters:
| Code: | | regsub -all \\W+ $string "" string |
...but I'm not sure this is what you really need (your wording makes me think you might be having problems related to treating strings as lists) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
vigilant Halfop
Joined: 05 Jan 2006 Posts: 48
|
Posted: Tue Dec 09, 2008 11:35 am Post subject: |
|
|
| 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: | | regsub -all \\W+ $string "" string |
...but I'm not sure this is what you really need (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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Dec 09, 2008 1:56 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
vigilant Halfop
Joined: 05 Jan 2006 Posts: 48
|
Posted: Tue Dec 09, 2008 1:59 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
vigilant Halfop
Joined: 05 Jan 2006 Posts: 48
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Dec 10, 2008 9:18 am Post subject: |
|
|
That is mentioned in the "Script Security" thread vigilant  _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
vigilant Halfop
Joined: 05 Jan 2006 Posts: 48
|
Posted: Wed Dec 10, 2008 11:05 am Post subject: |
|
|
| Sir_Fz wrote: | That is mentioned in the "Script Security" thread vigilant  |
lolllllllll Well great then :O _________________ Anser Quraishi
Website: http://www.anserq.com |
|
| Back to top |
|
 |
|