validator.w3.org fails if id attribute contains brackets
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 14 May 2006 14:59:46 +0000 (14:59 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 14 May 2006 14:59:46 +0000 (14:59 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11133 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/forms.php

index 7bc75e95d1f444ae51d647a902ceb1fa10832ce4..eacfaacaa8e81d8f492671093a97db09d29df49e 100644 (file)
@@ -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) {