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 

problem with http error

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


Joined: 14 Mar 2007
Posts: 1

PostPosted: Tue Mar 20, 2007 6:45 am    Post subject: problem with http error Reply with quote

Hi,
I have here a script which display the status of the user


Code:

proc web:read {nick host hand chan arg} {
global url

if {[llength $arg] == 0} { set statususer [split $nick]

} else {
   set statususer [split $arg]
}
   ::http::config -useragent "Mozilla/4.75 (X11; U; FreeBSD 6.1; i586; Nav)"
   set http [::http::data [::http::geturl $url$statususer]]
...



it works fine, but if in the $statususer a"[" or "]" it will call an error
Tcl error [web:read]: Illegal characters in URL path

simple question, how can I teach the bot to ignore this error ?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Mar 20, 2007 9:15 am    Post subject: Reply with quote

First off, this script is buggy. It uses list-commands on untrusted string sources, which is a very, very bad idea. Secondly, the composition of the url used with ::http::geturl does'nt make much sense to me; it's an external string(?) concatenated with a list (from either split:ing $nick or $arg).

split should not be used as an escaping-function; it only servers the purpose of converting a string into a list.

It would also be helpful with some information to which http-package/library you are using. My guess would be that you're using tcl's http-package version 2.x. However, I have not been able to find that error-message in any of the versions I have available.

But to your question, if you don't wish to solve this problem, but just make your bot ignore it, find which command causes the error, and enclose it in a catch-statement (see manpage for catch on how to do this).
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Tue Mar 20, 2007 9:31 pm    Post subject: Reply with quote

Some chars are not valid in url's, so you'd have to convert them to hex strings. For example, in the steamid script I made, I use:
Code:

# This is a global var, outside of any procs:

set sidmap {
"\ " +  : %3A  \\ %5C%5C  \[ %5B  \] %5D  \# %23  \" %22    \' %27  ! %21  @ %40
$ %24  \( %28  \) %29  ~  %7E  `  %60  %  %25   ^   %5E  \& %26  = %3D  + %2B
| %7C  \{ %7B  \} %7D  /  %2F  \? %3F  ,  %2C   <   %3C   > %3E  ; %3B
}

and then within procs to use the sidmap:
Code:

 set url [string map -nocase $::sidmap $url]

That's the basic idea, mine's slightly different (I use split on the input and then join within the set url part..)
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