Thread: [tclwebtest] Fix for a rare redirection problem with eval
Status: Abandoned
Brought to you by:
tils
From: Grzegorz A. H. <gr...@ef...> - 2003-08-22 11:58:57
Attachments:
eval_fix.diff.gz
|
Hi. I'm working now on an intranet for a client of us, and the restructuration led to a few new pages and redirections. These new redirections make tclwebtest fail testing units. The failure consists on a redirected url having a semicolon. The semicolon is parsed by eval as a command separation, thus, you get this output in the log: > [...] > --- do_request for http://192.168.1.50:8014/a-gastos/request-ae-2 > http status: >>302<< > following a redirect to: request-planning-travel?id=330&from=sel_new;one_req > --- do_request for http://192.168.1.50:8014/a-gastos/request-planning-travel?id=330&from=sel_new > http status: >>200<< > > invalid command name "one_req" > while executing > "one_req" > ("eval" body line 1) > invoked from within > "eval "do_request $nocomplain_option $followequiv_option $location"" > (procedure "do_request" line 134) > invoked from within > [...] As you can see, the `one_req' part of the url is parsed as a command. I didn't find any other way to solve this than create a temporary list for eval to use it. This way, parameters can have characters which eval could process with another meaning, like the semicolon. Til, are you ok with this patch? Is there any easier way to go around this? Gordon Molek, could you try this patch against your Apache server with httpauth and see if I have broken something? The patch works fine with tclwebtest's selftest directory and my own batch of unit tests, but I don't have any Apache to play. -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |
From: Tilmann S. <ti...@ti...> - 2003-08-22 14:24:54
|
Hi, Wouldn't it work to simply replace eval "do_request $nocomplain_option $followequiv_option $location" with eval {do_request $nocomplain_option $followequiv_option $location} ? I just did a simple test in tclsh which indicated that this should work, since then the variables get substituted during the eval run, not before which should work as well (and looks cleaner to me anyway). Unfortunately the selftests can't cover these things since they require interaction with a server, but if the fix above works for you feel free to commit it. cheers, Til -- http://tsinger.com |
From: Grzegorz A. H. <gr...@ef...> - 2003-08-22 16:16:30
Attachments:
curly_braces.diff.gz
|
On 2003-08-22, Tilmann Singer <ti...@ti...> wrote: > Hi, > > Wouldn't it work to simply replace [quotes with braces]? [...] Doesn't seem to. I replaced the quotes with braces (patch attached) and got: [...] > > --- do_request for http://192.168.1.50:8014/register/logout > > http status: >>302<< > > following a redirect to: http://192.168.1.50:8014/ > > > > Too many positional parameters specified > > while executing > > "do_request__arg_parser" > > (procedure "do_request" line 1) > > invoked from within > > "do_request $nocomplain_option $followequiv_option $location" > > ("eval" body line 1) > > invoked from within > > "eval {do_request $nocomplain_option $followequiv_option $location}" > > (procedure "do_request" line 134) > > invoked from within > > "do_request $LOGOUT_URL" > > ("uplevel" body line 1) > > invoked from within > > "uplevel $uplevel $to_eval " > > in script body line 0 [...] Maybe there's something more to do? I've read again the chapter about eval in my tcl manual and it says the difference between using a list and curly braces is that the latter doesn't make variable substitution immediate, which could be dangerous if the eval is going to be used in another scope. But I don't understand what this has to do with the "Too many positional parameters" thing. Evil tcl substitution rules... -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |
From: Tilmann S. <ti...@ti...> - 2003-08-22 18:15:19
|
* Grzegorz Adam Hankiewicz <gr...@ef...> [20030822 18:19]: > Maybe there's something more to do? I've read again the chapter > about eval in my tcl manual and it says the difference between using > a list and curly braces is that the latter doesn't make variable > substitution immediate, which could be dangerous if the eval is > going to be used in another scope. > > But I don't understand what this has to do with the "Too many > positional parameters" thing. Evil tcl substitution rules... Since the eval is not being used in another scope that shouldn't matter. Anyway rereading the eval man page I came to the following conclusion: eval do_request $nocomplain_option $followequiv_option $location seems to work fine. The 'too many positional' propably resulted from a space in one of the values, which is good because it warned us from an error that would have turned up later otherwise. You mind trying this new syntax? cheers, til -- http://tsinger.com |
From: Grzegorz A. H. <gr...@ef...> - 2003-08-26 07:11:17
|
On 2003-08-22, Tilmann Singer <ti...@ti...> wrote: > [...] You mind trying this new syntax? No luck: > [...] > --- do_request for http://192.168.1.50:8014/a-gastos/request-ae-2 > http status: >>302<< > following a redirect to: request-planning-travel?id=365&from=sel_new;one_req > --- do_request for http://192.168.1.50:8014/a-gastos/request-planning-travel?id=365&from=sel_new > http status: >>200<< > > invalid command name "one_req" > while executing > "one_req" > ("eval" body line 1) > invoked from within > "eval do_request $nocomplain_option $followequiv_option $location" > (procedure "do_request" line 134) > invoked from within > [...] -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |
From: Grzegorz A. H. <gr...@ef...> - 2003-08-26 07:48:49
|
On 2003-08-25, Grzegorz Adam Hankiewicz <gr...@ef...> wrote: > On 2003-08-22, Tilmann Singer <ti...@ti...> wrote: > > [...] You mind trying this new syntax? > [...] > > invalid command name "one_req" > > while executing > > "one_req" > > ("eval" body line 1) > > invoked from within > > "eval do_request $nocomplain_option $followequiv_option $location" > > (procedure "do_request" line 134) > > invoked from within > > [...] Simple shell tests fail too: $ tclsh % set ugh "Don't; like this" Don't; like this % eval puts $ugh Don't invalid command name "like" % set cmd [list puts $ugh] puts {Don't; like this} % eval $cmd Don't; like this % eval puts {$ugh} Don't; like this I think that the solution with braces would be ok if there were no empty parameters. In order to check which are empty or not, the proposed solution of building a list seems equally easy. I'm short of other suggestions. -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |
From: Grzegorz A. H. <gr...@ef...> - 2003-08-29 07:25:07
|
On 2003-08-22, Tilmann Singer <ti...@ti...> wrote: > Unfortunately the selftests can't cover these things since they > require interaction with a server, but if the fix above works > for you feel free to commit it. Commited then. -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |