Incorrect paths not returning a 404

Created on 24 August 2010, almost 14 years ago
Updated 23 February 2024, 4 months ago

I have a view page with a path set to foo/%/bar and an argument. When i browse to foo/123/bar/BAZ it returns the same result as foo/123/bar (where I guess it should return a 404). Has this happened to anyone and any idea how I can fix/troubleshoot it?

Thanks!

✨ Feature request
Status

Closed: won't fix

Version

2.11

Component

page displays

Created by

πŸ‡²πŸ‡ΉMalta sfa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • This behaviour can also be overridden for specific routes in a custom module using the following:

    /**
     * Implements hook_menu_get_item_alter().
     */
    function custom_module_menu_get_item_alter(&$router_item, $path, $original_map) {
      $router_path = $router_item['path'];
    
      if ($router_path === 'node/%' || $router_path === 'taxonomy/term/%') {
        if ($router_item['number_parts'] < count($original_map)) {
          $router_item['page_callback_original'] = $router_item['page_callback'];
          // Show a 404 response.
          $router_item['page_callback'] = 'custom_module_menu_not_found_callback';
        }
      }
    }
    
    /**
     * Callback to flag the response as not found.
     */
    function custom_module_menu_not_found_callback() {
      // drupal_not_found(); drupal_exit();
      return MENU_NOT_FOUND;
    }
    
    

    It could be theoretically made into a contrib module which allows users to set the max amount of URL components that are allowed for a specific menu route.

Production build 0.69.0 2024