From d101bba26551d50f1b9d79385ff8f7e108ccb663 Mon Sep 17 00:00:00 2001 From: webchick Date: Sun, 3 Jul 2011 10:58:46 -0700 Subject: [PATCH] Issue #978028 by Dave Reid: Fixed File token fixes: [file:description] does not exist and [file:owner] not using format_username(). --- modules/file/tests/file.test | 13 +++++-------- modules/system/system.tokens.inc | 11 ++--------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index ea8c5c67bb9..947247de992 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -1006,21 +1006,19 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { // Load the node and the file. $node = node_load($nid, NULL, TRUE); - $file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $file->description = 'File description.'; + $file = file_load($node->{$field_name}[LANGUAGE_NONE][0]['fid']); // Generate and test sanitized tokens. $tests = array(); $tests['[file:fid]'] = $file->fid; $tests['[file:name]'] = check_plain($file->filename); - $tests['[file:description]'] = filter_xss($file->description); - $tests['[file:path]'] = filter_xss($file->uri); - $tests['[file:mime]'] = filter_xss($file->filemime); + $tests['[file:path]'] = check_plain($file->uri); + $tests['[file:mime]'] = check_plain($file->filemime); $tests['[file:size]'] = format_size($file->filesize); - $tests['[file:url]'] = url(file_create_url($file->uri), $url_options); + $tests['[file:url]'] = check_plain(file_create_url($file->uri)); $tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language->language); $tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language->language); - $tests['[file:owner]'] = $this->admin_user->name; + $tests['[file:owner]'] = check_plain(format_username($this->admin_user)); $tests['[file:owner:uid]'] = $file->uid; // Test to make sure that we generated something for each token. @@ -1033,7 +1031,6 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { // Generate and test unsanitized tokens. $tests['[file:name]'] = $file->filename; - $tests['[file:description]'] = $file->description; $tests['[file:path]'] = $file->uri; $tests['[file:mime]'] = $file->filemime; $tests['[file:size]'] = format_size($file->filesize); diff --git a/modules/system/system.tokens.inc b/modules/system/system.tokens.inc index 27d7dfdb074..56ddf298804 100644 --- a/modules/system/system.tokens.inc +++ b/modules/system/system.tokens.inc @@ -88,10 +88,6 @@ function system_token_info() { 'name' => t("File name"), 'description' => t("The name of the file on disk."), ); - $file['description'] = array( - 'name' => t("Description"), - 'description' => t("An optional human-readable description of the file."), - ); $file['path'] = array( 'name' => t("Path"), 'description' => t("The location of the file relative to Drupal root."), @@ -228,10 +224,6 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a $replacements[$original] = $sanitize ? check_plain($file->filename) : $file->filename; break; - case 'description': - $replacements[$original] = $sanitize ? check_plain($file->description) : $file->description; - break; - case 'path': $replacements[$original] = $sanitize ? check_plain($file->uri) : $file->uri; break; @@ -255,7 +247,8 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a case 'owner': $account = user_load($file->uid); - $replacements[$original] = $sanitize ? check_plain($account->name) : $account->name; + $name = format_username($account); + $replacements[$original] = $sanitize ? check_plain($name) : $name; break; } }