You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2018/08/01 06:48:00 UTC

[jira] [Commented] (SLING-7796) Documentation: More details needed regarding ResourceResolver and /etc/map sling:redirect RegEx processing.

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

Konrad Windszus commented on SLING-7796:
----------------------------------------

What exactly is missing in https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html#root-level-mappings?

> Documentation: More details needed regarding ResourceResolver and /etc/map sling:redirect RegEx processing.
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-7796
>                 URL: https://issues.apache.org/jira/browse/SLING-7796
>             Project: Sling
>          Issue Type: Task
>          Components: ResourceResolver
>         Environment: Adobe Experience Manager 6.3
>            Reporter: Matthew
>            Priority: Minor
>              Labels: documentation
>
> +Primary Question:+
> How does the ResourceResolver RegEx engine process sling:redirect rules?
>  
> +Details:+
> Studying this page:
>  [http://localhost:4502/system/console/jcrresolver]
> And referencing this documentation:
>  [https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/resource-mapping.html#ViewingMappingDefinitions]
> I have some questions about the regEx processing.
> This excerpt taken from the reference document above does not make sense when evaluating the regEx:
> --------
> {noformat}
> For example, the:
> Pattern ^[^/]+/[^/]+/welcome$
> will trigger the:
> Replacement /libs/cq/core/content/welcome.html.
> to redirect a request:
> http://localhost:4503/welcome
> to:
> http://localhost:4503/libs/cq/core/content/welcome.html
> {noformat}
> ------------
> This regEx pattern reads as: "Match any string that does not start with a '/' character up to a '/' character and then any number of characters after the '/' that are not a '/' until a '/' is reached and then the characters 'welcome' that end the string with an 'e'.
> matches up to "http:/" but then does not match the rest of the string because there is a second '/'.
> The regEx would need to be:
> {noformat}
> ^[^/]+//[^/]+/welcome$
> {noformat}
> Notice the use of '//'.
> I have read all about namespace mangling and unmangling but I still cannot figure out how this rule matches.
> Further study took me into the /system/console/jcrresolver where I studied some ootb rules and some internal redirects that were created by configuring "vanity urls".
> An example internal ootb rule is:
> {noformat}
> ^[^/]+/[^/]+/sites$	=> /libs/wcm/core/content/sites.html
> {noformat}
> Two example vanity urls are:
> {noformat}
> ^[^/]+/[^/]+/2015DepartmentColloquia$ => /content/michigan-lsa/physics/en/news-events/all-events/archived-events/department-colloquia/2015-department-colloquium.html
> ^[^/]+/[^/]+/content/ii-directory/lrccs/en/educationalresources$ => /content/ii-directory/lrccs/en.html
> {noformat}
> And finally an example external url:
> {noformat}
> ^[^/]+/[^/]+/content/michigan-lsa/neurosci/en/studentinvolvement(\..*) => /content/michigan-lsa/neurosci/en/undergraduates/student-involvement$1
> {noformat}
> All of these examples have the same starting part of the regEx in common which is:
> {noformat}
> ^[^/]+/[^/]+/
> {noformat}
> Which would fail on all of the following test urls but somehow they work!
> {noformat}
> http://localhost:4502/welcome
> http://localhost:4502/sites
> http://localhost:4502/2015DepartmentColloquia
> http://localhost:4502/content/ii-directory/lrccs/en/educationalresources
> http://localhost:4502/content/michigan-lsa/neurosci/en/studentinvolvement
> These work too: (https protocol vs http: same urls)
> https://localhost:4502/welcome
> https://localhost:4502/sites
> https://localhost:4502/2015DepartmentColloquia
> https://localhost:4502/content/ii-directory/lrccs/en/educationalresources
> https://localhost:4502/content/michigan-lsa/neurosci/en/studentinvolvement
> {noformat}
> From studying it, I understand that somehow it must be consuming the '//' and then matching on the rest of the expression but I cannot understand how. I have also studied the following java code from Apache Sling:
>  org.apache.sling.resourceresolver-1.6.0 but am not able to pinpoint how this is working.
> ------------------------
> Questions:
>  How is this regEx processing working and why?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)