diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 83834b613ba6e1c576dec2e7112c2e7588ed430e..113275157a3e625534e57131b9fc764cadff9594 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -2104,7 +2104,7 @@ function comment_form_submit($form, &$form_state) { if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) { // Save the anonymous user information to a cookie for reuse. if (!$comment->uid) { - user_cookie_save($form_state['values']); + user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage')))); } comment_save($comment); diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc index dfe511069f38eca29fe4eaaf17f1960a9c591646..2ff99090a76714e28db1156a035e0bfcbe03e266 100644 --- a/modules/contact/contact.pages.inc +++ b/modules/contact/contact.pages.inc @@ -139,7 +139,7 @@ function contact_site_form_submit($form, &$form_state) { // Save the anonymous user information to a cookie for reuse. if (!$user->uid) { - user_cookie_save($values); + user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail')))); } // Get the to and from e-mail addresses. @@ -272,7 +272,7 @@ function contact_personal_form_submit($form, &$form_state) { // Save the anonymous user information to a cookie for reuse. if (!$user->uid) { - user_cookie_save($values); + user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail')))); } // Get the to and from e-mail addresses. diff --git a/modules/openid/openid.module b/modules/openid/openid.module index 96a74415a0cdd00b0c662135a581eb60e11349ef..afb6f86c14918ff44eaf929617888a9dbdec5611 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -84,7 +84,7 @@ function openid_user_insert(&$edit, $account, $category) { function openid_user_login(&$edit, $account) { if (isset($_SESSION['openid'])) { // The user has logged in via OpenID. - user_cookie_save($_SESSION['openid']['user_login_values'], array('openid_identifier')); + user_cookie_save(array_intersect_key($_SESSION['openid']['user_login_values'], array_flip(array('openid_identifier')))); unset($_SESSION['openid']); } } diff --git a/modules/system/system.module b/modules/system/system.module index eea5e90f058ad07752dddb9f53c5c0e20c7f5cf5..f2f06bfe797bf75e530341e848c378261eef0300 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2721,7 +2721,7 @@ function system_admin_compact_mode() { * Valid values are 'on' and 'off'. */ function system_admin_compact_page($mode = 'off') { - user_cookie_save(array('admin_compact_mode' => ($mode == 'on')), array('admin_compact_mode')); + user_cookie_save(array('admin_compact_mode' => ($mode == 'on'))); drupal_goto(); } diff --git a/modules/user/user.module b/modules/user/user.module index 40c475d92efd628ca9233fa4a5c0b8ad2ce6cad1..1441dc8316a524d21d6b91684205396a437a6a34 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -3494,17 +3494,12 @@ function user_login_destination() { * Saves visitor information as a cookie so it can be reused. * * @param $values - * An array of submitted form values with identifying information about the - * current user, typically $form_state['values'] from a submit handler. - * @param $fields - * An array of key values from $values to be saved into a cookie. - */ -function user_cookie_save(array $values, array $fields = array('name', 'mail', 'homepage')) { - foreach ($fields as $field) { - if (isset($values[$field])) { - // Set cookie for 365 days. - setrawcookie('Drupal.visitor.' . $field, rawurlencode($values[$field]), REQUEST_TIME + 31536000, '/'); - } + * An array of key/value pairs to be saved into a cookie. + */ +function user_cookie_save(array $values) { + foreach ($values as $field => $value) { + // Set cookie for 365 days. + setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), REQUEST_TIME + 31536000, '/'); } }