Skip to content

Commit

Permalink
Fixed some mod_rewrite compatibility problems. Fixes issue #563.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Jul 18, 2012
1 parent 538c2e5 commit 6fbbe01
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions NEWS
@@ -1,3 +1,13 @@
Release 3.0.14
--------------

* [Apache] Fixed a long-standing mod_rewrite-related problem.
Some mod_rewrite rules would not work, but it depends on the exact
mod_rewrite configuration so it would work for some people but not
for others. Issue #563. Thanks a lot to cedricmaion for providing
information on the nature of the bug.


Release 3.0.13
--------------

Expand Down
28 changes: 25 additions & 3 deletions ext/apache2/Hooks.cpp
Expand Up @@ -159,6 +159,7 @@ class Hooks {
char *filenameBeforeModRewrite;
apr_filetype_e oldFileType;
const char *handlerBeforeModAutoIndex;
bool enabled;

RequestNote(const DirectoryMapper &m, DirConfig *c)
: mapper(m),
Expand All @@ -169,6 +170,7 @@ class Hooks {
filenameBeforeModRewrite = NULL;
oldFileType = APR_NOFILE;
handlerBeforeModAutoIndex = NULL;
enabled = true;
}

~RequestNote() {
Expand Down Expand Up @@ -239,9 +241,25 @@ class Hooks {
* The existance of a request note means that the handler should be run.
*/
inline RequestNote *getRequestNote(request_rec *r) {
void *note = 0;
apr_pool_userdata_get(&note, "Phusion Passenger", r->pool);
return (RequestNote *) note;
void *pointer = 0;
apr_pool_userdata_get(&pointer, "Phusion Passenger", r->pool);
if (pointer != NULL) {
RequestNote *note = (RequestNote *) pointer;
if (OXT_LIKELY(note->enabled)) {
return note;
} else {
return 0;
}
} else {
return 0;
}
}

void disableRequestNote(request_rec *r) {
RequestNote *note = getRequestNote(r);
if (note != NULL) {
note->enabled = false;
}
}

/**
Expand Down Expand Up @@ -418,6 +436,7 @@ class Hooks {
try {
if (mapper.getBaseURI() == NULL) {
// (B) is not true.
disableRequestNote(r);
return false;
}
} catch (const FileSystemException &e) {
Expand All @@ -441,6 +460,7 @@ class Hooks {
RequestNote::cleanup, r->pool);
return true;
} else {
disableRequestNote(r);
return false;
}
}
Expand All @@ -451,6 +471,7 @@ class Hooks {
FileType fileType = getFileType(filename);
if (fileType == FT_REGULAR) {
// (C) is true.
disableRequestNote(r);
return false;
}

Expand Down Expand Up @@ -511,6 +532,7 @@ class Hooks {
* don't let the handler hook run so that Apache can decide how
* to display the error.
*/
disableRequestNote(r);
return false;
}
}
Expand Down

0 comments on commit 6fbbe01

Please sign in to comment.