diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-12-24 18:06:27 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-12-24 18:06:27 -0800 |
commit | 0f48b801736782736cad9281ad57bfa7a23e272a (patch) | |
tree | cbd91162145dc08f0d8f7d3baa4b954840789fb8 /modules/image | |
parent | aa8e8f4de83ca990a56e97ea317cee2bfc657a12 (diff) | |
download | brdo-0f48b801736782736cad9281ad57bfa7a23e272a.tar.gz brdo-0f48b801736782736cad9281ad57bfa7a23e272a.tar.bz2 |
Issue #1015916 by BTMash, jenlampton, theborg, Aron Novak, christefano, realityloop, xjm, Kevin Hankens: Fixed Image field 'title' allows more data than database column size.
Diffstat (limited to 'modules/image')
-rw-r--r-- | modules/image/image.field.inc | 5 | ||||
-rw-r--r-- | modules/image/image.install | 9 | ||||
-rw-r--r-- | modules/image/image.test | 17 |
3 files changed, 29 insertions, 2 deletions
diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index c3ac1d561..857e72ba8 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -403,7 +403,8 @@ function image_field_widget_process($element, &$form_state, $form) { '#type' => 'textfield', '#default_value' => isset($item['alt']) ? $item['alt'] : '', '#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.'), - '#maxlength' => variable_get('image_alt_length', 80), // See http://www.gawds.org/show.php?contentid=28. + // @see http://www.gawds.org/show.php?contentid=28 + '#maxlength' => 128, '#weight' => -2, '#access' => (bool) $item['fid'] && $settings['alt_field'], ); @@ -412,7 +413,7 @@ function image_field_widget_process($element, &$form_state, $form) { '#title' => t('Title'), '#default_value' => isset($item['title']) ? $item['title'] : '', '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'), - '#maxlength' => variable_get('image_title_length', 500), + '#maxlength' => 128, '#weight' => -1, '#access' => (bool) $item['fid'] && $settings['title_field'], ); diff --git a/modules/image/image.install b/modules/image/image.install index fc326b4e6..4edc32003 100644 --- a/modules/image/image.install +++ b/modules/image/image.install @@ -386,6 +386,15 @@ function image_update_7002(array &$sandbox) { } /** + * Remove the variables that set alt and title length since they were not + * used for database column size and could cause PDO exceptions. + */ +function image_update_7003() { + variable_del('image_alt_length'); + variable_del('image_title_length'); +} + +/** * Implements hook_requirements() to check the PHP GD Library. * * @param $phase diff --git a/modules/image/image.test b/modules/image/image.test index c9a709033..9cc06b935 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -786,6 +786,23 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $default_output = theme('image', $image_info); $this->assertRaw($default_output, t('Image displayed using user supplied alt and title attributes.')); + + // Verify that alt/title longer than allowed results in a validation error. + $test_size = 2000; + $max_size = 128; + $edit = array( + $field_name . '[' . LANGUAGE_NONE . '][0][alt]' => $this->randomName($test_size), + $field_name . '[' . LANGUAGE_NONE . '][0][title]' => $this->randomName($test_size), + ); + $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); + $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array( + '%max' => $max_size, + '%length' => $test_size, + ))); + $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array( + '%max' => $max_size, + '%length' => $test_size, + ))); } /** |