Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

git-svn-id: svn://cherokee-project.com/cherokee/trunk@3123 5dc97367-9…

…7f1-0310-9951-d761b3857238
  • Loading branch information...
commit b93599f8b9ec7b2ba0f54b1b8a719b24c83fca2a 1 parent 1d828f0
@alobbs alobbs authored
View
5 ChangeLog
@@ -1,5 +1,10 @@
2009-04-16 Alvaro Lopez Ortega <alvaro@octality.com>
+ * cherokee/handler_redir.c, qa/228-Redir-Paths2.py,
+ qa/Makefile.am, qa/227-Redir-Paths.py: Fixes bug #432
+ http://code.google.com/p/cherokee/issues/detail?id=432
+ Now hidden redirections can use non-global paths.
+
* cherokee/handler_cgi_base.c, admin/ModuleCgi.py: It will be
handier for many people if {Fast,S,}CGIs have the error handler
bit set by default.
View
7 cherokee/handler_redir.c
@@ -141,14 +141,19 @@ match_and_substitute (cherokee_handler_redir_t *n)
ovector, rc);
+ /* Arguments */
cherokee_split_arguments (&conn->request, 0, &args, &len);
-
if (len > 0) {
cherokee_buffer_clean (&conn->query_string);
cherokee_buffer_add (&conn->query_string, args, len);
cherokee_buffer_drop_ending (&conn->request, len+1);
}
+ /* Non-global redirection */
+ if (conn->request.buf[0] != '/') {
+ cherokee_buffer_prepend_str (&conn->request, "/");
+ }
+
TRACE (ENTRIES, "Hidden redirect to: request=\"%s\" query_string=\"%s\"\n",
conn->request.buf, conn->query_string.buf);
View
36 qa/227-Redir-Paths.py
@@ -0,0 +1,36 @@
+from base import *
+
+SERVER = "redir_paths_1"
+MAGIC = 'Reproducing bug report #432'
+
+CONF = """
+vserver!2270!nick = %s
+vserver!2270!document_root = %s
+
+vserver!2270!rule!1!match = default
+vserver!2270!rule!1!handler = file
+
+vserver!2270!rule!10!match = request
+vserver!2270!rule!10!match!request = file.*
+vserver!2270!rule!10!handler = redir
+vserver!2270!rule!10!handler!rewrite!1!show = 0
+vserver!2270!rule!10!handler!rewrite!1!regex = (.*)
+vserver!2270!rule!10!handler!rewrite!1!substring = internal.txt
+"""
+
+class Test (TestBase):
+ def __init__ (self):
+ TestBase.__init__ (self, __file__)
+ self.name = "Internal Redir: Paths"
+ self.request = "GET /in/file.foo HTTP/1.1\r\n" + \
+ "Host: %s\r\n" % (SERVER) + \
+ "Connection: Close\r\n"
+ self.expected_error = 200
+ self.expected_content = MAGIC
+
+ def Prepare (self, www):
+ d = self.Mkdir (www, "%s_droot/in"%(SERVER))
+ self.WriteFile (d, "internal.txt", 0444, MAGIC)
+
+ self.conf = CONF % (SERVER, d)
+
View
37 qa/228-Redir-Paths2.py
@@ -0,0 +1,37 @@
+from base import *
+
+DIR = "/deep/inside/bar/foo"
+SERVER = "redir_paths_2"
+MAGIC = 'Reproducing bug report #432'
+
+CONF = """
+vserver!2280!nick = %s
+vserver!2280!document_root = %s
+
+vserver!2280!rule!1!match = default
+vserver!2280!rule!1!handler = file
+
+vserver!2280!rule!10!match = directory
+vserver!2280!rule!10!match!directory = %s
+vserver!2280!rule!10!handler = redir
+vserver!2280!rule!10!handler!rewrite!1!show = 0
+vserver!2280!rule!10!handler!rewrite!1!regex = (.*)
+vserver!2280!rule!10!handler!rewrite!1!substring = internal.txt
+"""
+
+class Test (TestBase):
+ def __init__ (self):
+ TestBase.__init__ (self, __file__)
+ self.name = "Internal Redir, Directory match: Paths "
+ self.request = "GET /%s/file.foo HTTP/1.1\r\n" %(DIR) + \
+ "Host: %s\r\n" % (SERVER) + \
+ "Connection: Close\r\n"
+ self.expected_error = 200
+ self.expected_content = MAGIC
+
+ def Prepare (self, www):
+ d = self.Mkdir (www, "%s_droot/%s"%(SERVER, DIR))
+ self.WriteFile (d, "internal.txt", 0444, MAGIC)
+
+ self.conf = CONF % (SERVER, d, DIR)
+
View
4 qa/Makefile.am
@@ -231,7 +231,9 @@ run-tests.py \
223-EVHost2.py \
224-EVHost3.py \
225-PathTranslated.py \
-226-PathInfo-Default.py
+226-PathInfo-Default.py \
+227-Redir-Paths.py \
+228-Redir-Paths2.py
test:
Please sign in to comment.
Something went wrong with that request. Please try again.