summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-04-15 01:03:18 +0000
committerGo MAEDA <maeda@farend.jp>2021-04-15 01:03:18 +0000
commit2027b8750aa8f6432cf58fc5b0f8bf15ef8a03d8 (patch)
tree747658ec69365d995a09fb3416516868c0fa2a21 /lib
parente65980dc0995ee94f399f2d7e0d1b56b8ac6af57 (diff)
downloadredmine-2027b8750aa8f6432cf58fc5b0f8bf15ef8a03d8.tar.gz
redmine-2027b8750aa8f6432cf58fc5b0f8bf15ef8a03d8.zip
Prevent hash type URLs from being namespaced in MenuManager (#35076).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@20945 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/menu_manager.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb
index 16315a725..6378b19ba 100644
--- a/lib/redmine/menu_manager.rb
+++ b/lib/redmine/menu_manager.rb
@@ -180,14 +180,14 @@ module Redmine
url = '#'
options.reverse_merge!(:onclick => 'return false;')
end
- link_to(h(caption), url, options)
+ link_to(h(caption), use_absolute_controller(url), options)
end
def render_unattached_menu_item(menu_item, project)
raise MenuError, ":child_menus must be an array of MenuItems" unless menu_item.is_a? MenuItem
if menu_item.allowed?(User.current, project)
- link_to(menu_item.caption, menu_item.url, menu_item.html_options)
+ link_to(menu_item.caption, use_absolute_controller(menu_item.url), menu_item.html_options)
end
end
@@ -232,6 +232,15 @@ module Redmine
node.allowed?(user, project)
end
+
+ # Prevent hash type URLs (e.g. {controller: 'foo', action: 'bar}) from being namespaced
+ # when menus are rendered from views in namespaced controllers in plugins or engines
+ def use_absolute_controller(url)
+ if url.is_a?(Hash) && url[:controller].present? && !url[:controller].start_with?('/')
+ url[:controller] = "/#{url[:controller]}"
+ end
+ url
+ end
end
class << self