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

#HostUriMatchMapItems[]=example.com;;examle; given in site.ini as example is wrong

    XMLWordPrintable

    Details

      Description

      Hello

      I'm testing host_uri in site.ini, and I've detected a problem:
      This setting is working:

      HostUriMatchMapItems[]=adminezpublish11.poseidon.dev;;ezwebin_site_clean_admin
      

      But not this one, (that exists however on site.ini documentation that explains HostUriMatchMapItems, see bug summary):

      HostUriMatchMapItems[]=adminezpublish11.poseidon.dev;;ezwebin_site_clean_admin;
      

      The cause is due to last ';', for eZ it thinks the matchHostMethod is defined, but it is not strict, nore start, nore end, nore part, it's just empty, so it's an unknown matchHostMethod

      I really think that eZ should check the matchHostMethod, if it's defined AND empty, then keep using the defaultHostMatchMethod.

      Have a look at ezsiteaccess.php, on line 289, you'll understand quickly.
      Here is the code for finding matchHostMethod that will fail with matchMapItem[3] === ''

      $matchHost       = $matchMapItem[0];
                                  $matchURI        = $matchMapItem[1];
                                  $matchAccess     = $matchMapItem[2];
                                  $matchHostMethod = isset( $matchMapItem[3] ) ? $matchMapItem[3] : $defaultHostMatchMethod;
      
                                  if ( $matchURI !== '' && $matchURI !== $match_item )
                                      continue;
      
                                  switch( $matchHostMethod )
                                  {
                                      case 'strict':
                                      {
                                          $hasHostMatch = ( $matchHost === $host );
                                      } break;
                                      case 'start':
                                      {
                                          $hasHostMatch = ( strpos($host, $matchHost) === 0 );
                                      } break;
                                      case 'end':
                                      {
                                          $hasHostMatch = ( strstr($host, $matchHost) === $matchHost );
                                      } break;
                                      case 'part':
                                      {
                                          $hasHostMatch = ( strpos($host, $matchHost) !== false );
                                      } break;
                                      default:
                                      {
                                          $hasHostMatch = false;
                                          eZDebug::writeError( "Unknown host_uri host match: $matchHostMethod", "access" );
                                      } break;
                                  }
      

      I would change the line:

      $matchHostMethod = isset( $matchMapItem[3] ) ? $matchMapItem[3] : $defaultHostMatchMethod;
      

      in something like:

      $matchHostMethod = (isset( $matchMapItem[3] ) && trim($matchMapItem[3]) )? $matchMapItem[3] : $defaultHostMatchMethod;
      

      Or if you want to avoid the test of empty matchMapItem for performance, please update the documentation in site.ini that says that you can't use an empty host match method

        Attachments

          Activity

            People

            Assignee:
            andre1 André R
            Reporter:
            enzo Jerome Despatis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: