Loading modules/user/user.test +19 −0 Original line number Diff line number Diff line Loading @@ -2566,6 +2566,25 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase { $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input))); } } /** * Uses an anonymous user, then tests the tokens generated from it. */ function testAnonymousUserTokenReplacement() { global $language; // Load anonymous user data. $account = drupal_anonymous_user(); // Generate and test sanitized tokens. $tests = array(); $tests['[user:mail]'] = ''; foreach ($tests as $input => $expected) { $output = token_replace($input, array('user' => $account), array('language' => $language)); $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input))); } } } /** Loading modules/user/user.tokens.inc +6 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,12 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'mail': if (empty($account->mail)) { $replacements[$original] = ''; } else { $replacements[$original] = $sanitize ? check_plain($account->mail) : $account->mail; } break; case 'url': Loading Loading
modules/user/user.test +19 −0 Original line number Diff line number Diff line Loading @@ -2566,6 +2566,25 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase { $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input))); } } /** * Uses an anonymous user, then tests the tokens generated from it. */ function testAnonymousUserTokenReplacement() { global $language; // Load anonymous user data. $account = drupal_anonymous_user(); // Generate and test sanitized tokens. $tests = array(); $tests['[user:mail]'] = ''; foreach ($tests as $input => $expected) { $output = token_replace($input, array('user' => $account), array('language' => $language)); $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input))); } } } /** Loading
modules/user/user.tokens.inc +6 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,12 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'mail': if (empty($account->mail)) { $replacements[$original] = ''; } else { $replacements[$original] = $sanitize ? check_plain($account->mail) : $account->mail; } break; case 'url': Loading