same menu item titles = duplicate id values in markup = invalid markup

nicholas.keiser - November 20, 2007 - 01:28
Project:YUI Menu
Version:5.x-2.3
Component:Code
Category:bug report
Priority:critical
Assigned:drupalhizmetleri
Status:closed
Description

At present, generation of id values from menu titles in line 236 of yuimenu.module is as follows:


$output .= '<div id="'. rep_char($menu['visible'][$mid]['title']).'" class="yuimenu">

This can result in duplicate id values in markup and subsequent validation failure if there are menu items in different sections of the menu which have the same title (which Drupal does allow).

I would make a reccomendation but the only thing that comes to mind is some check and subsequent handling of this (i.e. testing for and appending "-a", "-b", etc in event of duplicate values) and that seems rough around the edges. I also don't need individual id values for each menu item in the project I'm currently working on, so it was easier to strip out the id generating bit altogether; obviously, though, this isn't a real fix. ...

#1

mariuss - December 27, 2007 - 22:00
Priority:normal» critical

Same issue here, but it gets worse. If the title contains special characters, an ampersand for example, then they will end up in the ID, and the ID will be invalid (and as a result the whole page will fail validation).

Instead of using menu titles for IDs why not use the menu id, the $mid variable. This should be prefixed with something like "yui_menu_".

#2

mariuss - December 27, 2007 - 22:08
Version:5.x-2.2» 5.x-2.3

Forgot to mention that this still happens in 2.3, where str_replace was added around rep_char.

#3

drupalhizmetleri - January 12, 2008 - 12:17
Assigned to:Anonymous» drupalhizmetleri

Thanks. Next version will create id with $mid variable and will loke like id="yui_menu_id_67".

#4

drupalhizmetleri - January 13, 2008 - 10:45

is it possible to test the version yuimenu 5.x-2.x-dev ?

#5

drupalhizmetleri - January 13, 2008 - 10:45
Status:active» fixed

#6

mariuss - January 14, 2008 - 02:47

Looks good to me.

#7

Anonymous (not verified) - January 28, 2008 - 02:51
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.