Feature #24808 » 0002-Prevent-hash-type-URLs-from-being-namespaced-in-Menu.patch
lib/redmine/menu_manager.rb | ||
---|---|---|
177 | 177 |
url = '#' |
178 | 178 |
options.reverse_merge!(:onclick => 'return false;') |
179 | 179 |
end |
180 |
link_to(h(caption), url, options)
|
|
180 |
link_to(h(caption), use_absolute_controller(url), options)
|
|
181 | 181 |
end |
182 | 182 | |
183 | 183 |
def render_unattached_menu_item(menu_item, project) |
184 | 184 |
raise MenuError, ":child_menus must be an array of MenuItems" unless menu_item.is_a? MenuItem |
185 | 185 | |
186 | 186 |
if menu_item.allowed?(User.current, project) |
187 |
link_to(menu_item.caption, menu_item.url, menu_item.html_options)
|
|
187 |
link_to(menu_item.caption, use_absolute_controller(menu_item.url), menu_item.html_options)
|
|
188 | 188 |
end |
189 | 189 |
end |
190 | 190 | |
... | ... | |
225 | 225 |
raise MenuError, ":child_menus must be an array of MenuItems" unless node.is_a? MenuItem |
226 | 226 |
node.allowed?(user, project) |
227 | 227 |
end |
228 | ||
229 |
# Prevent hash type URLs (e.g. {controller: 'foo', action: 'bar}) from being namespaced |
|
230 |
# when menus are rendered from views in namespaced controllers in plugins or engines |
|
231 |
def use_absolute_controller(url) |
|
232 |
if url.is_a?(Hash) && url[:controller].present? && !url[:controller].start_with?('/') |
|
233 |
url[:controller] = "/#{url[:controller]}" |
|
234 |
end |
|
235 |
url |
|
236 |
end |
|
228 | 237 |
end |
229 | 238 | |
230 | 239 |
class << self |