Bug 44729 - Redirect accepts anything as first argument instead of only HTTP status codes.
Summary: Redirect accepts anything as first argument instead of only HTTP status codes.
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_alias (show other bugs)
Version: 2.2.8
Hardware: All All
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2008-04-01 10:31 UTC by Sönke Tesch
Modified: 2009-07-13 15:26 UTC (History)
0 users



Attachments
Enforce Redirect argument types / Consistent args / Better error messages. (2.42 KB, patch)
2008-04-01 10:31 UTC, Sönke Tesch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Tesch 2008-04-01 10:31:36 UTC
Created attachment 21754 [details]
Enforce Redirect argument types / Consistent args / Better error messages.

#1

Given three arguments to mod_alias/Redirect, the first one should be a HTTP status code, followed by the old and the new, target URL. However, Redirect silently accepts arguments like

Redirect bla / http://anywhere

takes bla as a URL and redirects it to / (and in turn ignores http://anywhere), instead of complaining that "bla" is not a valid HTTP status code.

While this is a minor violation of the docs, it frequently bugs the user (read: me) whenever he (me) gets tricked by remembering "Redirect permanent" into entering "Redirect temporary" instead of the correct "Redirect temp", thus adding useless Redirects, causing chaos and doom in the Web.

Since the bug on the user-side has been sitting there for years, won't get fixed soon and might already be considered a feature, I've appended a workaround patch to mod_alias to enforce the words as they've been written in the docs.


#2

The patch furthermore extends the argument list with perm (following the existing temp) and, more important, temporary (following the existing permanent). Makes usage more straight-forward and consistent.


#3

Added brackets to the if-blocks according to the Apache C style.


#4

While at it, I've prepended "mod_alias/Redirect: " to add_redirect_internal()'s error messages. You might know that the line "Regular expression could not be compiled." in error_log comes from a Redirect statement (at least as long as you just modified one), however "mod_alias/Redirect: Regular expression could not be compiled." makes it 100% clear where to look.
Error messages should not be riddles, the error itself is enough.
Comment 1 Nick Kew 2009-05-26 17:59:11 UTC
I've committed the arguments checking part of your patch to trunk r778942 .  Don't agree with the error message changes: yours are out-of-line with other startup errors, and will tend to confuse ("why is this message different?").
Comment 2 Nick Kew 2009-07-13 15:26:00 UTC
Backported to 2.2 in r792917