Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7796

Documentation: More details needed regarding ResourceResolver and /etc/map sling:redirect RegEx processing.

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ResourceResolver
    • Labels:
    • Environment:
      Adobe Experience Manager 6.3

      Description

      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:

      --------

      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
      

      ------------

      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:

      ^[^/]+//[^/]+/welcome$
      

      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:

      ^[^/]+/[^/]+/sites$	=> /libs/wcm/core/content/sites.html
      

      Two example vanity urls are:

      ^[^/]+/[^/]+/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
      

      And finally an example external url:

      ^[^/]+/[^/]+/content/michigan-lsa/neurosci/en/studentinvolvement(\..*) => /content/michigan-lsa/neurosci/en/undergraduates/student-involvement$1
      

      All of these examples have the same starting part of the regEx in common which is:

      ^[^/]+/[^/]+/
      

      Which would fail on all of the following test urls but somehow they work!

      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
      

      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?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mcruz@umich.edu Matthew
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: