[ 
https://issues.apache.org/jira/browse/SLING-6996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16073632#comment-16073632
 ] 

Karl Pauls edited comment on SLING-6996 at 7/4/17 12:58 PM:
------------------------------------------------------------

In a nutshell, what happens is that we try to match two patterns for a given 
sling:match (namely, {{"http/([^/]+)(\\.[^\\d/]+)(/.*)?$"}} and 
{{"https/([^/]+)(\\.[^\\d/]+)(/.*)?$"}}). 

This is done to try to detect if we have a host without port (i.e., the pattern 
should match the default port of either http or https). 

If any of the two match we effectively try to massage the pattern by appending 
the default port via a replacement of: {{"http/$1$2.80$3"}} or 
{{"https/$1$2.443$3"}}, respectively.

This is clearly not allowing for certain valid regex patterns (including the 
ones given as examples in our own documentation). 

At this point, we can either try to make the detection regexes smarter (which 
I'm not sure is a good idea because it likely would make the expressions pretty 
complicated) or turn around double check if we didn't match a regex by accident 
after we found a match.

I'm attaching a patch for the latter in [^SLING-6996.patch]. 

[~cziegeler], what say you?


was (Author: karlpauls):
In a nutshell, what happens is that we try to match two patterns for a given 
sling:match (namely, "http/([^/]+)(\\.[^\\d/]+)(/.*)?$" and 
"https/([^/]+)(\\.[^\\d/]+)(/.*)?$"). 

This is done to try to detect if we have a host without port (i.e., the pattern 
should match the default port of either http or https). 

If any of the two match we effectively try to massage the pattern by appending 
the default port via a replacement of: "http/$1$2.80$3" or "https/$1$2.443$3", 
respectively.

This is clearly not allowing for certain valid regex patterns (including the 
ones given as examples in our own documentation). 

At this point, we can either try to make the detection regexes smarter (which 
I'm not sure is a good idea because it likely would make the expressions pretty 
complicated) or turn around double check if we didn't match a regex by accident 
after we found a match.

I'm attaching a patch for the latter in [^SLING-6996.patch]. 

[~cziegeler], what say you?

> Root Mappings for Resource Resolution don't work correctly when sling:match 
> contains a regex in the host part
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-6996
>                 URL: https://issues.apache.org/jira/browse/SLING-6996
>             Project: Sling
>          Issue Type: Bug
>          Components: ResourceResolver
>    Affects Versions: Resource Resolver 1.5.24
>            Reporter: Karl Pauls
>            Assignee: Karl Pauls
>             Fix For: Resource Resolver 1.5.26
>
>         Attachments: SLING-6996.patch
>
>
> Looking at 
> http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html#root-level-mappings
>  it should be possible to match ports in the sling:match e.g.:
> sling:match = http/localhost.\d*
> should match regardless of the host port. However, that currently isn't the 
> case as the resource resolver erroneously detects this as a host without port 
> and appends the default port to the pattern.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to