egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Replacing/Ignoring bad characters in code

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
vigilant
Halfop


Joined: 05 Jan 2006
Posts: 48

PostPosted: Mon Dec 08, 2008 9:39 pm    Post subject: [SOLVED] Replacing/Ignoring bad characters in code Reply with quote

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 Smile
_________________
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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Tue Dec 09, 2008 5:39 am    Post subject: Reply with quote

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 Wink (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
View user's profile Send private message
vigilant
Halfop


Joined: 05 Jan 2006
Posts: 48

PostPosted: Tue Dec 09, 2008 11:35 am    Post subject: Reply with quote

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 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
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Dec 09, 2008 1:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
vigilant
Halfop


Joined: 05 Jan 2006
Posts: 48

PostPosted: Tue Dec 09, 2008 1:59 pm    Post subject: Reply with quote

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 Smile Thanks for clarifying.
_________________
Anser Quraishi
Website: http://www.anserq.com
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Dec 09, 2008 2:35 pm    Post subject: Reply with quote

Script Security
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
vigilant
Halfop


Joined: 05 Jan 2006
Posts: 48

PostPosted: Tue Dec 09, 2008 10:07 pm    Post subject: Reply with quote

Sir_Fz wrote:
Script Security


I think better than that is, http://www.peterre.info/characters.html
_________________
Anser Quraishi
Website: http://www.anserq.com
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Dec 10, 2008 9:18 am    Post subject: Reply with quote

That is mentioned in the "Script Security" thread vigilant Smile
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
vigilant
Halfop


Joined: 05 Jan 2006
Posts: 48

PostPosted: Wed Dec 10, 2008 11:05 am    Post subject: Reply with quote

Sir_Fz wrote:
That is mentioned in the "Script Security" thread vigilant Smile


lolllllllll Smile Well great then :O
_________________
Anser Quraishi
Website: http://www.anserq.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber