X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fforms.php;h=361dd49db93299514d1f3b483e640af67dcce434;hb=f5b3b0fc5f07d42975b0a9104d4a70cadb254efa;hp=7bc75e95d1f444ae51d647a902ceb1fa10832ce4;hpb=47ccfad452e8d345542d09e59112cac317cffed8;p=squirrelmail.git diff --git a/functions/forms.php b/functions/forms.php index 7bc75e95..361dd49d 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) { @@ -291,5 +299,3 @@ function addForm($sAction, $sMethod = 'post', $sName = '', $sEnctype = '', $sCha return '
\n"; } - -?> \ No newline at end of file