From 5f817a0bc46fa47583ffce939e18c56570338bc3 Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 14 May 2006 14:59:46 +0000 Subject: [PATCH] validator.w3.org fails if id attribute contains brackets git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11133 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/forms.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/forms.php b/functions/forms.php index 7bc75e95..eacfaaca 100644 --- a/functions/forms.php +++ b/functions/forms.php @@ -50,7 +50,15 @@ function addInputField($sType, $aAttribs=array()) { $sAttribs = ''; // define unique identifier if (! isset($aAttribs['id']) && isset($aAttribs['name']) && ! is_null($aAttribs['name'])) { - $aAttribs['id'] = $aAttribs['name']; + /** + * if 'id' is not set, set it to 'name' and replace brackets + * with underscores. 'name' might contain field name with squire + * brackets (array). Brackets are not allowed in id (validator.w3.org + * fails to validate document). According to html 4.01 manual cdata + * type description, 'name' attribute uses same type, but validator.w3.org + * does not barf on brackets in 'name' attributes. + */ + $aAttribs['id'] = strtr($aAttribs['name'],'[]','__'); } // create attribute string (do we have to sanitize keys?) foreach ($aAttribs as $key => $value) { -- 2.25.1