Bug 56528

Summary: "bad flags delimiter" - improve helpfulness
Product: Apache httpd-2 Reporter: Edward Lu <Chaosed0>
Component: mod_rewriteAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: enhancement Keywords: FixedInTrunk, PatchAvailable
Priority: P2    
Version: 2.5-HEAD   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Improve error reporting in mod_rewrite
Improve error reporting in mod_rewrite

Description Edward Lu 2014-05-15 14:33:48 UTC
Created attachment 31627 [details]
Improve error reporting in mod_rewrite

The parser in mod_rewrite always interprets the third argument to RewriteRule/RewriteCond as optional flags. However, unescaped whitespace is fairly easy to accidentally insert into a RewriteRule/RewriteCond directive. When this happens, "bad flag delimiters" is displayed since the rogue whitespace causes the parser to interpret a chunk of one of the args as flags. This error is a spectacularly bad way to express this (even if it's strictly true).

The attached patch attempts to improve the error reporting of the relevant section in mod_rewrite.
Comment 1 Eric Covener 2014-06-03 13:23:23 UTC
This seems to trigger on:

RewriteRule .* - [G]

RewriteRule: bad flag delimiters: third argument must end with ']' but found [G] - unintended whitespace within the flags definition? (pattern='.*', substitution='-', flags='[G]')
Comment 2 Edward Lu 2014-06-03 13:53:07 UTC
Created attachment 31685 [details]
Improve error reporting in mod_rewrite

Silly of me - forgot my order of operations.
Comment 3 Eric Covener 2015-01-16 19:44:27 UTC
Thanks, committed to trunk in r1652507.

(reminded of this patch by my own whitespace typo in RewriteCond)