Permalink
Browse files

MDL-31213 fix incorrect modifications of quickforms attributes

  • Loading branch information...
1 parent 09249fe commit c444939ec7a06cfa0a1d744b8129966b8dec9fa6 @skodak skodak committed Jan 17, 2012
Showing with 21 additions and 6 deletions.
  1. +7 −2 lib/form/password.php
  2. +7 −2 lib/form/passwordunmask.php
  3. +7 −2 lib/formslib.php
@@ -19,9 +19,14 @@ function MoodleQuickForm_password($elementName=null, $elementLabel=null, $attrib
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete of passwords
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
- $attributes = (array)$attributes;
- if (!isset($attributes['autocomplete'])) {
+ if (empty($attributes)) {
+ $attributes = array('autocomplete'=>'off');
+ } else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
+ } else {
+ if (strpos($attributes, 'autocomplete') === false) {
+ $attributes .= ' autocomplete="off" ';
+ }
}
}
@@ -19,9 +19,14 @@ function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete of passwords
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
- $attributes = (array)$attributes;
- if (!isset($attributes['autocomplete'])) {
+ if (empty($attributes)) {
+ $attributes = array('autocomplete'=>'off');
+ } else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
+ } else {
+ if (strpos($attributes, 'autocomplete') === false) {
+ $attributes .= ' autocomplete="off" ';
+ }
}
}
View
@@ -110,9 +110,14 @@ function moodleform($action=null, $customdata=null, $method='post', $target='',
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete with the exception of user signup
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
- $attributes = (array)$attributes;
- if (!isset($attributes['autocomplete'])) {
+ if (empty($attributes)) {
+ $attributes = array('autocomplete'=>'off');
+ } else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
+ } else {
+ if (strpos($attributes, 'autocomplete') === false) {
+ $attributes .= ' autocomplete="off" ';
+ }
}
}

0 comments on commit c444939

Please sign in to comment.