diff --git a/core/includes/form.inc b/core/includes/form.inc
index 513615c..201357e 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2529,6 +2529,9 @@ function form_type_select_value($element, $input = FALSE) {
  */
 function form_type_textfield_value($element, $input = FALSE) {
   if ($input !== FALSE && $input !== NULL) {
+    if ($element['#trim']) {
+      $input = trim($input);
+    }
     // Equate $input to the form value to ensure it's marked for
     // validation.
     return str_replace(array("\r", "\n"), '', $input);
@@ -2536,6 +2539,25 @@ function form_type_textfield_value($element, $input = FALSE) {
 }
 
 /**
+ * Determines the value for a textarea form element.
+ *
+ * @param $element
+ *   The form element whose value is being populated.
+ * @param $input
+ *   The incoming input to populate the form element. If this is FALSE,
+ *   the element's default value should be returned.
+ *
+ * @return
+ *   The data that will appear in the $element_state['values'] collection
+ *   for this element. Return nothing to use the default.
+ */
+function form_type_textarea_value($element, $input = FALSE) {
+  if ($element['#trim']) {
+    $input = trim($input);
+  }
+}
+
+/**
  * Determines the value for form's token value.
  *
  * @param $element
@@ -2984,8 +3006,10 @@ function form_process_password_confirm($element) {
  * Validates a password_confirm element.
  */
 function password_confirm_validate($element, &$element_state) {
-  $pass1 = trim($element['pass1']['#value']);
-  $pass2 = trim($element['pass2']['#value']);
+  if ($element['#trim']) {
+    $pass1 = trim($element['pass1']['#value']);
+    $pass2 = trim($element['pass2']['#value']);
+  }
   if (!empty($pass1) || !empty($pass2)) {
     if (strcmp($pass1, $pass2)) {
       form_error($element, t('The specified passwords do not match.'));
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index c958f27..a91468a 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -308,11 +308,11 @@ function _node_characters($length) {
  */
 function node_type_form_validate($form, &$form_state) {
   $type = new stdClass();
-  $type->type = trim($form_state['values']['type']);
-  $type->name = trim($form_state['values']['name']);
+  $type->type = $form_state['values']['type'];
+  $type->name = $form_state['values']['name'];
 
   // Work out what the type was before the user submitted this form
-  $old_type = trim($form_state['values']['old_type']);
+  $old_type = $form_state['values']['old_type'];
 
   $types = node_type_get_names();
 
@@ -341,9 +341,9 @@ function node_type_form_submit($form, &$form_state) {
 
   $type = node_type_set_defaults();
 
-  $type->type = trim($form_state['values']['type']);
-  $type->name = trim($form_state['values']['name']);
-  $type->orig_type = trim($form_state['values']['orig_type']);
+  $type->type = $form_state['values']['type'];
+  $type->name = $form_state['values']['name'];
+  $type->orig_type = $form_state['values']['orig_type'];
   $type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
 
   $type->description = $form_state['values']['description'];
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 106ef14..6d8509f 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -326,6 +326,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#size' => 60,
     '#maxlength' => 128,
+    '#trim' => TRUE,
     '#autocomplete_path' => FALSE,
     '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
     '#pre_render' => array('form_pre_render_textfield'),
@@ -420,6 +421,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#size' => 60,
     '#maxlength' => 128,
+    '#trim' => TRUE,
     '#process' => array('ajax_process_form', 'form_process_pattern'),
     '#pre_render' => array('form_pre_render_password'),
     '#theme' => 'input__password',
@@ -434,6 +436,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#cols' => 60,
     '#rows' => 5,
+    '#trim' => FALSE,
     '#resizable' => 'vertical',
     '#process' => array('ajax_process_form'),
     '#theme' => 'textarea',
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index 4da13b8..0237871 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -1019,9 +1019,6 @@ function user_admin_role($form, $form_state, $role) {
  * Form submit handler for the user_admin_role() form.
  */
 function user_admin_role_submit($form, &$form_state) {
-  // Prevent leading and trailing spaces in role names.
-  $form_state['values']['role']['label'] = trim($form_state['values']['role']['label']);
-
   $role = entity_create('user_role', $form_state['values']['role']);
   if ($role->save() == SAVED_UPDATED) {
     drupal_set_message(t('The role has been renamed.'));
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 4500c9b..2ea6fce 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1320,7 +1320,7 @@ function user_login_name_validate($form, &$form_state) {
  * is set to the matching user ID.
  */
 function user_login_authenticate_validate($form, &$form_state) {
-  $password = trim($form_state['values']['pass']);
+  $password = $form_state['values']['pass'];
   $flood_config = config('user.flood');
   if (!empty($form_state['values']['name']) && !empty($password)) {
     // Do not allow any login from the current user's IP if the limit has been
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 5a872ab..0f3afa3 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -78,7 +78,7 @@ function user_pass() {
 }
 
 function user_pass_validate($form, &$form_state) {
-  $name = trim($form_state['values']['name']);
+  $name = $form_state['values']['name'];
   // Try to load by email.
   $users = entity_load_multiple_by_properties('user', array('mail' => $name, 'status' => '1'));
   $account = reset($users);
