Balamurugan-R / wub

Automatically exported from code.google.com/p/wub
0 stars 0 forks source link

Nub.tcl - proc code_trailing generates a bad switch body. #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I downloaded the exampels from wubwikit and tried to run example 1.

What is the expected output? What do you see instead?
expected - a web age.
result.  - error page.
Error Code 'NONE'

extra switch pattern with no body
    while executing
"switch -glob -- "[dict get $r -host],[dict get $r -path]/" { {
        Http Redir $r [dict get $r -path]/
    }
        default {
        NotFound $r
        }
    }"
    (procedure "trailing" line 2)
    invoked from within
"trailing $r"
    (procedure "do" line 32)
    invoked from within
"do REQUEST [pre $r]"

What version of the product are you using? On what operating system?
did a svn checkout.revisoni 3345.

Please provide any additional information below.
$ svn log Nub.tcl | less
------------------------------------------------------------------------
r3258 | mcccol | 2010-08-17 19:44:36 -0500 (Tue, 17 Aug 2010) | 2 lines

* added default facility to redirect URLs which would match if there were a 
trailing / to that URL

did a diff between that and previous version.

and found this.
+    proc code_trailing {processed} {
+       upvar 1 domains domains
+       set switch ""
+       foreach {u d} $processed {
+           set url [join [lassign $u host] /]
+           Debug.nub {code_trailing: $u ($d)}
+           dict with d {
+               lappend switch "$host,$url*"
+           }
+       }
+       set switch [join $switch " -\n"]
+       append switch { {
+           Http Redir $r [dict get $r -path]/
+       }}
+       append switch {
+           default {
+               NotFound $r
+           }
+       }
+
+       # set up a selector to specify trailing/
+       set selector {"[dict get $r -host],[dict get $r -path]/"}
+       set body "Debug.nub {trailing: \[dict get \$r -host],\[dict get \$r 
-path]/}"
+       append body \n
+       append body "set result \[switch -glob -- $selector [list $switch]\]" \n
+       append body "Debug.nub {trailing: \[dict get? \$result -code] \[dict 
get? \$result location]}" \n
+       append body "return \$result"
+
+       Debug.nub {code_trailing: ($body)}
+       eval "::proc ::Httpd::trailing {r} [list $body]"
+    }
+

That code generates a bad switch body.
Quick glance and I couldn't see exactly what this code was trying to do.  

Original issue reported on code.google.com by tircnf on 8 Nov 2010 at 11:52

GoogleCodeExporter commented 8 years ago
Not sure if you looked at this or not, but it's caused because the wubwikit 
examples don't have a site.config file and don't set up any default URLs.

if this thing is called with an empty list it generates a bad switch body.

Original comment by tircnf on 29 Apr 2011 at 6:36

GoogleCodeExporter commented 8 years ago
Thanks for finding this.  The objective is to take the set of URLs which have 
been used to match and dispatch, and if they have failed, to try to redirect 
them with a trailing '/'

The idea is that if you specify an http://example.com/url/ and someone tries to 
GET http://example.com/url which fails, it will be redirected with the 
corrected URL.

It seems I need to account for the case that no URLs have been specified ... 
but how does wubwikit function without any URLs specified?  They added 
dynamically?

I'll fix the null case.

Original comment by firstros...@gmail.com on 30 Apr 2011 at 1:28

GoogleCodeExporter commented 8 years ago
I must confess I'm not sure how (or if) the wubwikit examples used to work.

I found them from the wub wiki page, 
http://wiki.tcl.tk/15781

and they are here.
http://code.google.com/p/wubwikit/source/browse/#svn/trunk/wubexamples

If you download example 1 and try to run it you get that bad switch body error.

I assume that back when this example was created that wub would default to a 
file domain for ./docroot but I haven't searched through old svn versions.

Is there a better place to find some wub examples?

Original comment by tircnf on 30 Apr 2011 at 1:45

GoogleCodeExporter commented 8 years ago
Tried to simply catch the no-processed case, generating a NotFound.  Let me 
know if that doesn't work.  I'm still puzzled as to how wubwikit does what it 
does.

Original comment by firstros...@gmail.com on 30 Apr 2011 at 2:09

GoogleCodeExporter commented 8 years ago

Original comment by mcc...@gmail.com on 30 Apr 2011 at 2:25