Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-31217

Bad recognition/test between uri and excluded_uri_prefixes

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: High High
    • None
    • 2.5.6
    • php 7.2

      ezplatform 2.5.6 with legacyBridge

    Description

      we have an issue using excluded_uri_prefixes and naming a content within our siteaccess the same prefix as item in excluded_uri_prefixes.

      This is the Yaml Configuration : 

      ezpublish: 
          system: 
              my_siteaccess: 
                  content: 
                      tree_root: 
                          excluded_uri_prefixes: [ "/Ressources/", "/Media/"

      Our siteaccess is level 2 below rootLocation /home and /Ressources is at the same level as our siteaccess.rootLocation /My_Siteaccess

      Home
          Ressources
          My_Siteaccess
              Ressources-Educatives

      On frontoffice, links are good in our menu (/My_Siteaccess/Ressources-Educatives) but when clicking on it, urlAliasGenerator recognise prefixes /Ressources and redirect on it, even if we add a slash at the end of /Ressources/.

      Recognition is done in UrlAliasGenerator.isUriPrefixExcluded function.
      cf. https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/Core/MVC/Symfony/Routing/Generator/UrlAliasGenerator.php#L149

      As you trim all slashes from item in excluded_uri_prefixes, the ending slash is not taken in account and all ressources starting with /Ressources would be redirected to /Ressources. 
      I solve the issue by changing : 

      $excludedPrefix = '/' . trim($excludedPrefix, '/');

      to `ltrim`

      $excludedPrefix = '/' . ltrim($excludedPrefix, '/');
      

      and it works fine, i'm not redirected anymore on /Ressources when accessing /Ressources-Educatives

      Another workaround should be :

      public function isUriPrefixExcluded($uri) 
      { 
          $uri = preg_match('/\/$/', $uri) ? $uri : $uri . '/'; 
          foreach ($this->excludedUriPrefixes as $excludedPrefix) 
          { 
              $excludedPrefix = '/' . trim($excludedPrefix, '/') . '/'; 
              if (mb_stripos($uri, $excludedPrefix) === 0) 
              { 
                   return true; 
              } 
          } 
      
          return false; 
      }
      

      Hope it helps.

       

      ps: i open a support.ez.no issue asap. 

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            6cb48d3d-6972-4c0a-b2f1-2d0c289c7511@accounts.ibexa.co Flo HUCK
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: