Commit a36ff846 authored by alexpott's avatar alexpott

Issue #920056 by Dave Reid, andypost, quietone, rkjha, Alumei: Fixed...

Issue #920056 by Dave Reid, andypost, quietone, rkjha, Alumei: Fixed [comment:name] duplicates [comment:author], and the latter should use format_username().
parent fa2be71e
......@@ -37,10 +37,6 @@ function comment_token_info() {
'name' => t("IP Address"),
'description' => t("The IP address of the computer the comment was posted from."),
);
$comment['name'] = array(
'name' => t("Name"),
'description' => t("The name left by the comment author."),
);
$comment['mail'] = array(
'name' => t("Email address"),
'description' => t("The email address left by the comment author."),
......@@ -96,7 +92,7 @@ function comment_token_info() {
);
$comment['author'] = array(
'name' => t("Author"),
'description' => t("The author of the comment, if they were logged in."),
'description' => t("The author name of the comment."),
'type' => 'user',
);
......@@ -173,9 +169,6 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
$replacements[$original] = $comment->url('edit-form', $url_options);
break;
// @todo Remove 'name' token in favour of 'author'. See
// https://drupal.org/node/920056.
case 'name':
case 'author':
$name = $comment->getAuthorName();
$replacements[$original] = $sanitize ? Xss::filter($name) : $name;
......
......@@ -51,7 +51,6 @@ function testCommentTokenReplacement() {
$tests = array();
$tests['[comment:cid]'] = $comment->id();
$tests['[comment:hostname]'] = String::checkPlain($comment->getHostname());
$tests['[comment:name]'] = Xss::filter($comment->getAuthorName());
$tests['[comment:author]'] = Xss::filter($comment->getAuthorName());
$tests['[comment:mail]'] = String::checkPlain($this->admin_user->getEmail());
$tests['[comment:homepage]'] = check_url($comment->getHomepage());
......@@ -78,7 +77,6 @@ function testCommentTokenReplacement() {
// Generate and test unsanitized tokens.
$tests['[comment:hostname]'] = $comment->getHostname();
$tests['[comment:name]'] = $comment->getAuthorName();
$tests['[comment:author]'] = $comment->getAuthorName();
$tests['[comment:mail]'] = $this->admin_user->getEmail();
$tests['[comment:homepage]'] = $comment->getHomepage();
......@@ -93,6 +91,15 @@ function testCommentTokenReplacement() {
$this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input)));
}
// Test anonymous comment author.
$author_name = $this->randomString();
$comment->setOwnerId(0)->setAuthorName($author_name);
$input = '[comment:author]';
$output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()));
$this->assertEqual($output, Xss::filter($author_name), format_string('Sanitized comment author token %token replaced.', array('%token' => $input)));
$output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
$this->assertEqual($output, $author_name, format_string('Unsanitized comment author token %token replaced.', array('%token' => $input)));
// Load node so comment_count gets computed.
$node = node_load($node->id());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment