AEM Dispatcher filter - how to make case insensitive? | Community
Skip to main content
Level 2
July 23, 2018
Question

AEM Dispatcher filter - how to make case insensitive?

  • July 23, 2018
  • 7 replies
  • 4647 views

Hi I'm sure this question must have been answered or explained somewhere but I've not found it yet

The Adobe product pages explain Configuring Dispatcher.  I'd like to filter out requests based on file extension similar to the example in the documentation,

Example filter: Using Regular Expressions

This filter enables extensions in non-public content directories using a regular expression, defined here between single quotes:

1

/005  {  /type "allow" /extension '(css|gif|ico|js|png|swf|jpe?g)' }

I'd like our rule to be case insensitive, so that files uploaded, with naming such as 'foo.jpg', 'foo.JpeG' and 'foo.JPG' are all allowed by a filter rule like this.  As it's a regular expression, I would expect to be able to amend the regex example to '(css|gif|ico|js|png|swf|jpe?g)/i' but this doesn't seem to work.

Does anyone know how to make this extension rule case insensitive?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

arunpatidar
Community Advisor
Community Advisor
July 23, 2018

HI,

I am not sure if below is helpful in your case, worth to give a try.

Mastering the AEM Dispatcher Part 2: Case Insensitive URLs

Arun Patidar
Level 2
July 23, 2018

Thanks @@Arun Patidar​

I've seen the (excellent) blogs you linked to, but those concern the Apache mod_rewrite module.  I'm working in the dispatcher.any file  (i.e. configuring Apache mod_dispatcher).

The Adobe filter documentation (see my link above) says

so I hoped a simple tweak to the regex "...defined here between single quotes..." would make the filter ignore case.  But my suggestion above doesn't work.  How do I write a dispatcher.any filter that ignores case?

arunpatidar
Community Advisor
Community Advisor
July 23, 2018

Hi,

I am not sure how to do that, I am unable to test in my machine but you can try below if helps

'(css|gif|ico|js|png|swf|jpe?g)'/i

'(css|gif|ico|js|png|swf|jpe?g)'i

Arun Patidar
Level 2
July 23, 2018

thanks for your suggestions Arun Patidar

My reading of the documentation's "...regular expression, defined here between single quotes..." was that the regex literally had to be 'between...quotes' but i gave your suggestions a try nevertheless (presumably you saw what i said I had tried in the original question above?).

Unfortunately neither of those worked.

joerghoh
Adobe Employee
Adobe Employee
July 23, 2018

As suggested I would just convert all extensions to lowercase using mod_rewrite. Although the dispatcher might support regular expressions, I don't assume that it will support all modifiers you are used from the PCRE.

Jörg

Level 2
July 24, 2018

Thanks @@Jörg Hoh​

I'm not looking to support all modifiers from the PCRE just this one (case-insensitivity)  and as a starting point, if I can avoid having to maintain configuration in two different places to achieve one thing, then I would rather do that.

As a follow-up question, do you know where can I reference exactly what flavour of regex the dispatcher does support?

thanks

Level 2
July 24, 2018

If i can't pin down a regex case insensitive flag for the Dispatcher, amending the filter's regex to something like the following seems to work, (though it's not particularly readable)

AEM_Dan
Level 3
December 14, 2022

I am disappointed to see the dispatcher still does not allow for case insensitive extensions.  Or at least on v4.3.3 which is what I am using. @joej47544984   Can you share your regex?  I don't see it in the post above.