security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -2,13 +2,14 @@
/**
* @file
* Admin page callbacks for the filter module.
* Administrative page callbacks for the Filter module.
*/
/**
* Menu callback; Displays a list of all text formats and allows them to be rearranged.
* Page callback: Form constructor for a form to list and reorder text formats.
*
* @ingroup forms
* @see filter_menu()
* @see filter_admin_overview_submit()
*/
function filter_admin_overview($form) {
@@ -45,6 +46,9 @@ function filter_admin_overview($form) {
return $form;
}
/**
* Form submission handler for filter_admin_overview().
*/
function filter_admin_overview_submit($form, &$form_state) {
foreach ($form_state['values']['formats'] as $id => $data) {
if (is_array($data) && isset($data['weight'])) {
@@ -95,7 +99,26 @@ function theme_filter_admin_overview($variables) {
}
/**
* Menu callback; Display a text format form.
* Page callback: Displays the text format add/edit form.
*
* @param object|null $format
* (optional) An object representing a format, with the following properties:
* - format: A machine-readable name representing the ID of the text format
* to save. If this corresponds to an existing text format, that format
* will be updated; otherwise, a new format will be created.
* - name: The title of the text format.
* - cache: (optional) An integer indicating whether the text format is
* cacheable (1) or not (0). Defaults to 1.
* - status: (optional) An integer indicating whether the text format is
* enabled (1) or not (0). Defaults to 1.
* - weight: (optional) The weight of the text format, which controls its
* placement in text format lists. If omitted, the weight is set to 0.
* Defaults to NULL.
*
* @return
* A form array.
*
* @see filter_menu()
*/
function filter_admin_format_page($format = NULL) {
if (!isset($format->name)) {
@@ -109,11 +132,24 @@ function filter_admin_format_page($format = NULL) {
}
/**
* Generate a text format form.
* Form constructor for the text format add/edit form.
*
* @param $format
* A format object having the properties:
* - format: A machine-readable name representing the ID of the text format to
* save. If this corresponds to an existing text format, that format will be
* updated; otherwise, a new format will be created.
* - name: The title of the text format.
* - cache: An integer indicating whether the text format is cacheable (1) or
* not (0). Defaults to 1.
* - status: (optional) An integer indicating whether the text format is
* enabled (1) or not (0). Defaults to 1.
* - weight: (optional) The weight of the text format, which controls its
* placement in text format lists. If omitted, the weight is set to 0.
*
* @ingroup forms
* @see filter_admin_format_form_validate()
* @see filter_admin_format_form_submit()
* @ingroup forms
*/
function filter_admin_format_form($form, &$form_state, $format) {
$is_fallback = ($format->format == filter_fallback_format());
@@ -287,7 +323,9 @@ function theme_filter_admin_format_filter_order($variables) {
}
/**
* Validate text format form submissions.
* Form validation handler for filter_admin_format_form().
*
* @see filter_admin_format_form_submit()
*/
function filter_admin_format_form_validate($form, &$form_state) {
$format_format = trim($form_state['values']['format']);
@@ -304,7 +342,9 @@ function filter_admin_format_form_validate($form, &$form_state) {
}
/**
* Process text format form submissions.
* Form submission handler for filter_admin_format_form().
*
* @see filter_admin_format_form_validate()
*/
function filter_admin_format_form_submit($form, &$form_state) {
// Remove unnecessary values.
@@ -336,10 +376,14 @@ function filter_admin_format_form_submit($form, &$form_state) {
}
/**
* Menu callback; confirm deletion of a format.
* Form constructor for the text format deletion confirmation form.
*
* @ingroup forms
* @param $format
* An object representing a text format.
*
* @see filter_menu()
* @see filter_admin_disable_submit()
* @ingroup forms
*/
function filter_admin_disable($form, &$form_state, $format) {
$form['#format'] = $format;
@@ -353,7 +397,7 @@ function filter_admin_disable($form, &$form_state, $format) {
}
/**
* Process filter disable form submission.
* Form submission handler for filter_admin_disable().
*/
function filter_admin_disable_submit($form, &$form_state) {
$format = $form['#format'];
@@ -362,4 +406,3 @@ function filter_admin_disable_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/config/content/formats';
}

View File

@@ -57,20 +57,20 @@
* - description: Additional administrative information about the filter's
* behavior, if needed for clarification.
* - settings callback: The name of a function that returns configuration form
* elements for the filter. See hook_filter_FILTER_settings() for details.
* elements for the filter. See callback_filter_settings() for details.
* - default settings: An associative array containing default settings for
* the filter, to be applied when the filter has not been configured yet.
* - prepare callback: The name of a function that escapes the content before
* the actual filtering happens. See hook_filter_FILTER_prepare() for
* the actual filtering happens. See callback_filter_prepare() for
* details.
* - process callback: (required) The name the function that performs the
* actual filtering. See hook_filter_FILTER_process() for details.
* actual filtering. See callback_filter_process() for details.
* - cache (default TRUE): Specifies whether the filtered text can be cached.
* Note that setting this to FALSE makes the entire text format not
* cacheable, which may have an impact on the site's overall performance.
* See filter_format_allowcache() for details.
* - tips callback: The name of a function that returns end-user-facing filter
* usage guidelines for the filter. See hook_filter_FILTER_tips() for
* usage guidelines for the filter. See callback_filter_tips() for
* details.
* - weight: A default weight for the filter in new text formats.
*
@@ -122,11 +122,9 @@ function hook_filter_info_alter(&$info) {
*/
/**
* Settings callback for hook_filter_info().
* Provide a settings form for filter settings.
*
* Note: This is not really a hook. The function name is manually specified via
* 'settings callback' in hook_filter_info(), with this recommended callback
* name pattern. It is called from filter_admin_format_form().
* Callback for hook_filter_info().
*
* This callback function is used to provide a settings form for filter
* settings, for filters that need settings on a per-text-format basis. This
@@ -158,8 +156,10 @@ function hook_filter_info_alter(&$info) {
* @return
* An array of form elements defining settings for the filter. Array keys
* should match the array keys in $filter->settings and $defaults.
*
* @ingroup callbacks
*/
function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
function callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
$filter->settings += $defaults;
$elements = array();
@@ -172,11 +172,9 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def
}
/**
* Prepare callback for hook_filter_info().
* Provide prepared text with special characters escaped.
*
* Note: This is not really a hook. The function name is manually specified via
* 'prepare callback' in hook_filter_info(), with this recommended callback
* name pattern. It is called from check_markup().
* Callback for hook_filter_info().
*
* See hook_filter_info() for a description of the filtering process. Filters
* should not use the 'prepare callback' step for anything other than escaping,
@@ -199,19 +197,19 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def
*
* @return
* The prepared, escaped text.
*
* @ingroup callbacks
*/
function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
function callback_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
// Escape <code> and </code> tags.
$text = preg_replace('|<code>(.+?)</code>|se', "[codefilter_code]$1[/codefilter_code]", $text);
return $text;
}
/**
* Process callback for hook_filter_info().
* Provide text filtered to conform to the supplied format.
*
* Note: This is not really a hook. The function name is manually specified via
* 'process callback' in hook_filter_info(), with this recommended callback
* name pattern. It is called from check_markup().
* Callback for hook_filter_info().
*
* See hook_filter_info() for a description of the filtering process. This step
* is where the filter actually transforms the text.
@@ -232,19 +230,19 @@ function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache,
*
* @return
* The filtered text.
*
* @ingroup callbacks
*/
function hook_filter_FILTER_process($text, $filter, $format, $langcode, $cache, $cache_id) {
function callback_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
$text = preg_replace('|\[codefilter_code\](.+?)\[/codefilter_code\]|se', "<pre>$1</pre>", $text);
return $text;
}
/**
* Tips callback for hook_filter_info().
* Return help text for a filter.
*
* Note: This is not really a hook. The function name is manually specified via
* 'tips callback' in hook_filter_info(), with this recommended callback
* name pattern. It is called from _filter_tips().
* Callback for hook_filter_info().
*
* A filter's tips should be informative and to the point. Short tips are
* preferably one-liners.
@@ -260,8 +258,10 @@ function hook_filter_FILTER_process($text, $filter, $format, $langcode, $cache,
*
* @return
* Translated text to display as a tip.
*
* @ingroup callbacks
*/
function hook_filter_FILTER_tips($filter, $format, $long) {
function callback_filter_tips($filter, $format, $long) {
if ($long) {
return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
}

View File

@@ -6,3 +6,9 @@ core = 7.x
files[] = filter.test
required = TRUE
configure = admin/config/content/formats
; Information added by Drupal.org packaging script on 2015-04-02
version = "7.36"
project = "drupal"
datestamp = "1427943826"

View File

@@ -2,7 +2,7 @@
/**
* @file
* Install, update and uninstall functions for the filter module.
* Install, update, and uninstall functions for the Filter module.
*/
/**

View File

@@ -2,7 +2,7 @@
/**
* @file
* Framework for handling filtering of content.
* Framework for handling the filtering of content.
*/
/**
@@ -71,6 +71,7 @@ function filter_theme() {
* Implements hook_element_info().
*
* @see filter_process_format()
* @see text_format_wrapper()
*/
function filter_element_info() {
$type['text_format'] = array(
@@ -132,13 +133,16 @@ function filter_menu() {
}
/**
* Access callback for deleting text formats.
* Access callback: Checks access for disabling text formats.
*
* @param $format
* A text format object.
*
* @return
* TRUE if the text format can be disabled by the current user, FALSE
* otherwise.
*
* @see filter_menu()
*/
function _filter_disable_format_access($format) {
// The fallback format can never be disabled.
@@ -146,7 +150,7 @@ function _filter_disable_format_access($format) {
}
/**
* Load a text format object from the database.
* Loads a text format object from the database.
*
* @param $format_id
* The format ID.
@@ -164,29 +168,32 @@ function filter_format_load($format_id) {
}
/**
* Save a text format object to the database.
* Saves a text format object to the database.
*
* @param $format
* A format object using the properties:
* - 'format': A machine-readable name representing the ID of the text format
* A format object having the properties:
* - format: A machine-readable name representing the ID of the text format
* to save. If this corresponds to an existing text format, that format
* will be updated; otherwise, a new format will be created.
* - 'name': The title of the text format.
* - 'status': (optional) An integer indicating whether the text format is
* - name: The title of the text format.
* - status: (optional) An integer indicating whether the text format is
* enabled (1) or not (0). Defaults to 1.
* - 'weight': (optional) The weight of the text format, which controls its
* - weight: (optional) The weight of the text format, which controls its
* placement in text format lists. If omitted, the weight is set to 0.
* - 'filters': (optional) An associative, multi-dimensional array of filters
* - filters: (optional) An associative, multi-dimensional array of filters
* assigned to the text format, keyed by the name of each filter and using
* the properties:
* - 'weight': (optional) The weight of the filter in the text format. If
* - weight: (optional) The weight of the filter in the text format. If
* omitted, either the currently stored weight is retained (if there is
* one), or the filter is assigned a weight of 10, which will usually
* put it at the bottom of the list.
* - 'status': (optional) A boolean indicating whether the filter is
* - status: (optional) A boolean indicating whether the filter is
* enabled in the text format. If omitted, the filter will be disabled.
* - 'settings': (optional) An array of configured settings for the filter.
* - settings: (optional) An array of configured settings for the filter.
* See hook_filter_info() for details.
*
* @return
* SAVED_NEW or SAVED_UPDATED.
*/
function filter_format_save($format) {
$format->name = trim($format->name);
@@ -271,7 +278,7 @@ function filter_format_save($format) {
}
/**
* Disable a text format.
* Disables a text format.
*
* There is no core facility to re-enable a disabled format. It is not deleted
* to keep information for contrib and to make sure the format ID is never
@@ -313,7 +320,15 @@ function filter_format_exists($format_id) {
}
/**
* Display a text format form title.
* Displays a text format form title.
*
* @param object $format
* A format object.
*
* @return string
* The name of the format.
*
* @see filter_menu()
*/
function filter_admin_format_title($format) {
return $format->name;
@@ -333,9 +348,7 @@ function filter_permission() {
foreach (filter_formats() as $format) {
$permission = filter_permission_name($format);
if (!empty($permission)) {
// Only link to the text format configuration page if the user who is
// viewing this will have access to that page.
$format_name_replacement = user_access('administer filters') ? l($format->name, 'admin/config/content/formats/' . $format->format) : drupal_placeholder($format->name);
$format_name_replacement = l($format->name, 'admin/config/content/formats/' . $format->format);
$perms[$permission] = array(
'title' => t("Use the !text_format text format", array('!text_format' => $format_name_replacement,)),
'description' => drupal_placeholder(t('Warning: This permission may have security implications depending on how the text format is configured.')),
@@ -350,6 +363,7 @@ function filter_permission() {
*
* @param $format
* An object representing a text format.
*
* @return
* The machine-readable permission name, or FALSE if the provided text format
* is malformed or is the fallback format (which is available to all users).
@@ -380,11 +394,13 @@ function filter_modules_disabled($modules) {
}
/**
* Retrieve a list of text formats, ordered by weight.
* Retrieves a list of text formats, ordered by weight.
*
* @param $account
* (optional) If provided, only those formats that are allowed for this user
* account will be returned. All formats will be returned otherwise.
* account will be returned. All formats will be returned otherwise. Defaults
* to NULL.
*
* @return
* An array of text format objects, keyed by the format ID and ordered by
* weight.
@@ -427,7 +443,7 @@ function filter_formats($account = NULL) {
}
/**
* Resets text format caches.
* Resets the text format caches.
*
* @see filter_formats()
*/
@@ -443,6 +459,7 @@ function filter_formats_reset() {
*
* @param $format
* An object representing the text format.
*
* @return
* An array of role names, keyed by role ID.
*/
@@ -461,6 +478,7 @@ function filter_get_roles_by_format($format) {
*
* @param $rid
* The user role ID to retrieve text formats for.
*
* @return
* An array of text format objects that are allowed for the role, keyed by
* the text format ID and ordered by weight.
@@ -494,7 +512,8 @@ function filter_get_formats_by_role($rid) {
*
* @param $account
* (optional) The user account to check. Defaults to the currently logged-in
* user.
* user. Defaults to NULL.
*
* @return
* The ID of the user's default text format.
*
@@ -525,15 +544,18 @@ function filter_default_format($account = NULL) {
* format is initialized to output plain text. Installation profiles and site
* administrators have the freedom to configure it further.
*
* Note that the fallback format is completely distinct from the default
* format, which differs per user and is simply the first format which that
* user has access to. The default and fallback formats are only guaranteed to
* be the same for users who do not have access to any other format; otherwise,
* the fallback format's weight determines its placement with respect to the
* user's other formats.
* Note that the fallback format is completely distinct from the default format,
* which differs per user and is simply the first format which that user has
* access to. The default and fallback formats are only guaranteed to be the
* same for users who do not have access to any other format; otherwise, the
* fallback format's weight determines its placement with respect to the user's
* other formats.
*
* Any modules implementing a format deletion functionality must not delete
* this format.
* Any modules implementing a format deletion functionality must not delete this
* format.
*
* @return
* The ID of the fallback text format.
*
* @see hook_filter_format_disable()
* @see filter_default_format()
@@ -550,6 +572,9 @@ function filter_fallback_format() {
/**
* Returns the title of the fallback text format.
*
* @return string
* The title of the fallback text format.
*/
function filter_fallback_format_title() {
$fallback_format = filter_format_load(filter_fallback_format());
@@ -557,7 +582,10 @@ function filter_fallback_format_title() {
}
/**
* Return a list of all filters provided by modules.
* Returns a list of all filters provided by modules.
*
* @return array
* An array of filter formats.
*/
function filter_get_filters() {
$filters = &drupal_static(__FUNCTION__, array());
@@ -588,14 +616,16 @@ function filter_get_filters() {
}
/**
* Helper function for sorting the filter list by filter name.
* Sorts an array of filters by filter name.
*
* Callback for uasort() within filter_get_filters().
*/
function _filter_list_cmp($a, $b) {
return strcmp($a['title'], $b['title']);
}
/**
* Check if text in a certain text format is allowed to be cached.
* Checks if the text in a certain text format is allowed to be cached.
*
* This function can be used to check whether the result of the filtering
* process can be cached. A text format may allow caching depending on the
@@ -603,6 +633,7 @@ function _filter_list_cmp($a, $b) {
*
* @param $format_id
* The text format ID to check.
*
* @return
* TRUE if the given text format allows caching, FALSE otherwise.
*/
@@ -619,6 +650,7 @@ function filter_format_allowcache($format_id) {
*
* @param $format
* The text format object to check.
*
* @return
* TRUE if all the filters enabled in the given text format allow caching,
* FALSE otherwise.
@@ -640,7 +672,7 @@ function _filter_format_is_cacheable($format) {
}
/**
* Retrieve a list of filters for a given text format.
* Retrieves a list of filters for a given text format.
*
* Note that this function returns all associated filters regardless of whether
* they are enabled or disabled. All functions working with the filter
@@ -694,7 +726,7 @@ function filter_list_format($format_id) {
}
/**
* Run all the enabled filters on a piece of text.
* Runs all the enabled filters on a piece of text.
*
* Note: Because filters can inject JavaScript or execute PHP code, security is
* vital here. When a user supplies a text format, you should validate it using
@@ -705,16 +737,20 @@ function filter_list_format($format_id) {
* @param $text
* The text to be filtered.
* @param $format_id
* The format id of the text to be filtered. If no format is assigned, the
* fallback format will be used.
* (optional) The machine name of the filter format to be used to filter the
* text. Defaults to the fallback format. See filter_fallback_format().
* @param $langcode
* Optional: the language code of the text to be filtered, e.g. 'en' for
* (optional) The language code of the text to be filtered, e.g. 'en' for
* English. This allows filters to be language aware so language specific
* text replacement can be implemented.
* text replacement can be implemented. Defaults to an empty string.
* @param $cache
* Boolean whether to cache the filtered output in the {cache_filter} table.
* The caller may set this to FALSE when the output is already cached
* elsewhere to avoid duplicate cache lookups and storage.
* (optional) A Boolean indicating whether to cache the filtered output in the
* {cache_filter} table. The caller may set this to FALSE when the output is
* already cached elsewhere to avoid duplicate cache lookups and storage.
* Defaults to FALSE.
*
* @return
* The filtered text.
*
* @ingroup sanitization
*/
@@ -784,8 +820,8 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
* the text format id specified in #format or the user's default format by
* default, if NULL.
*
* The resulting value for the element will be an array holding the value and the
* format. For example, the value for the body element will be:
* The resulting value for the element will be an array holding the value and
* the format. For example, the value for the body element will be:
* @code
* $form_state['values']['body']['value'] = 'foo';
* $form_state['values']['body']['format'] = 'foo';
@@ -795,7 +831,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
* The form element to process. Properties used:
* - #base_type: The form element #type to use for the 'value' element.
* 'textarea' by default.
* - #format: (optional) The text format id to preselect. If NULL or not set,
* - #format: (optional) The text format ID to preselect. If NULL or not set,
* the default format for the current user will be used.
*
* @return
@@ -933,7 +969,7 @@ function filter_process_format($element) {
}
/**
* #pre_render callback for #type 'text_format' to hide field value from prying eyes.
* Render API callback: Hides the field value of 'text_format' elements.
*
* To not break form processing and previews if a user does not have access to a
* stored text format, the expanded form elements in filter_process_format() are
@@ -976,7 +1012,7 @@ function theme_text_format_wrapper($variables) {
* An object representing the text format.
* @param $account
* (optional) The user account to check access for; if omitted, the currently
* logged-in user is used.
* logged-in user is used. Defaults to NULL.
*
* @return
* Boolean TRUE if the user is allowed to access the given format.
@@ -998,7 +1034,20 @@ function filter_access($format, $account = NULL) {
}
/**
* Helper function for fetching filter tips.
* Retrieves the filter tips.
*
* @param $format_id
* The ID of the text format for which to retrieve tips, or -1 to return tips
* for all formats accessible to the current user.
* @param $long
* (optional) Boolean indicating whether the long form of tips should be
* returned. Defaults to FALSE.
*
* @return
* An associative array of filtering tips, keyed by filter name. Each
* filtering tip is an associative array with elements:
* - tip: Tip text.
* - id: Filter ID.
*/
function _filter_tips($format_id, $long = FALSE) {
global $user;
@@ -1032,14 +1081,14 @@ function _filter_tips($format_id, $long = FALSE) {
/**
* Parses an HTML snippet and returns it as a DOM object.
*
* This function loads the body part of a partial (X)HTML document
* and returns a full DOMDocument object that represents this document.
* You can use filter_dom_serialize() to serialize this DOMDocument
* back to a XHTML snippet.
* This function loads the body part of a partial (X)HTML document and returns
* a full DOMDocument object that represents this document. You can use
* filter_dom_serialize() to serialize this DOMDocument back to a XHTML
* snippet.
*
* @param $text
* The partial (X)HTML snippet to load. Invalid mark-up
* will be corrected on import.
* The partial (X)HTML snippet to load. Invalid mark-up will be corrected on
* import.
* @return
* A DOMDocument that represents the loaded (X)HTML snippet.
*/
@@ -1054,15 +1103,14 @@ function filter_dom_load($text) {
/**
* Converts a DOM object back to an HTML snippet.
*
* The function serializes the body part of a DOMDocument
* back to an XHTML snippet.
*
* The resulting XHTML snippet will be properly formatted
* to be compatible with HTML user agents.
* The function serializes the body part of a DOMDocument back to an XHTML
* snippet. The resulting XHTML snippet will be properly formatted to be
* compatible with HTML user agents.
*
* @param $dom_document
* A DOMDocument object to serialize, only the tags below
* the first <body> node will be converted.
*
* @return
* A valid (X)HTML snippet, as a string.
*/
@@ -1099,9 +1147,11 @@ function filter_dom_serialize($dom_document) {
* @param $dom_element
* The element potentially containing a CDATA node.
* @param $comment_start
* String to use as a comment start marker to escape the CDATA declaration.
* (optional) A string to use as a comment start marker to escape the CDATA
* declaration. Defaults to '//'.
* @param $comment_end
* String to use as a comment end marker to escape the CDATA declaration.
* (optional) A string to use as a comment end marker to escape the CDATA
* declaration. Defaults to an empty string.
*/
function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '') {
foreach ($dom_element->childNodes as $node) {
@@ -1156,7 +1206,7 @@ function theme_filter_guidelines($variables) {
/**
* @defgroup standard_filters Standard filters
* @{
* Filters implemented by the filter.module.
* Filters implemented by the Filter module.
*/
/**
@@ -1204,7 +1254,9 @@ function filter_filter_info() {
}
/**
* Settings callback for the HTML filter.
* Implements callback_filter_settings().
*
* Filter settings callback for the HTML content filter.
*/
function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) {
$filter->settings += $defaults;
@@ -1230,7 +1282,9 @@ function _filter_html_settings($form, &$form_state, $filter, $format, $defaults)
}
/**
* HTML filter. Provides filtering of input into accepted HTML.
* Implements callback_filter_process().
*
* Provides filtering of input into accepted HTML.
*/
function _filter_html($text, $filter) {
$allowed_tags = preg_split('/\s+|<|>/', $filter->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY);
@@ -1249,7 +1303,11 @@ function _filter_html($text, $filter) {
}
/**
* Filter tips callback for HTML filter.
* Implements callback_filter_tips().
*
* Provides help for the HTML filter.
*
* @see filter_filter_info()
*/
function _filter_html_tips($filter, $format, $long = FALSE) {
global $base_url;
@@ -1347,7 +1405,11 @@ function _filter_html_tips($filter, $format, $long = FALSE) {
}
/**
* Settings callback for URL filter.
* Implements callback_filter_settings().
*
* Provides settings for the URL filter.
*
* @see filter_filter_info()
*/
function _filter_url_settings($form, &$form_state, $filter, $format, $defaults) {
$filter->settings += $defaults;
@@ -1366,7 +1428,9 @@ function _filter_url_settings($form, &$form_state, $filter, $format, $defaults)
}
/**
* URL filter. Automatically converts text into hyperlinks.
* Implements callback_filter_process().
*
* Converts text into hyperlinks automatically.
*
* This filter identifies and makes clickable three types of "links".
* - URLs like http://example.com.
@@ -1395,7 +1459,7 @@ function _filter_url($text, $filter) {
// we cannot cleanly differ between protocols here without hard-coding MAILTO,
// so '//' is optional for all protocols.
// @see filter_xss_bad_protocol()
$protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp'));
$protocols = variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal'));
$protocols = implode(':(?://)?|', $protocols) . ':(?://)?';
// Prepare domain name pattern.
@@ -1489,7 +1553,9 @@ function _filter_url($text, $filter) {
}
/**
* preg_replace callback to make links out of absolute URLs.
* Makes links out of absolute URLs.
*
* Callback for preg_replace_callback() within _filter_url().
*/
function _filter_url_parse_full_links($match) {
// The $i:th parenthesis in the regexp contains the URL.
@@ -1502,7 +1568,9 @@ function _filter_url_parse_full_links($match) {
}
/**
* preg_replace callback to make links out of e-mail addresses.
* Makes links out of e-mail addresses.
*
* Callback for preg_replace_callback() within _filter_url().
*/
function _filter_url_parse_email_links($match) {
// The $i:th parenthesis in the regexp contains the URL.
@@ -1515,7 +1583,9 @@ function _filter_url_parse_email_links($match) {
}
/**
* preg_replace callback to make links out of domain names starting with "www."
* Makes links out of domain names starting with "www."
*
* Callback for preg_replace_callback() within _filter_url().
*/
function _filter_url_parse_partial_links($match) {
// The $i:th parenthesis in the regexp contains the URL.
@@ -1528,14 +1598,17 @@ function _filter_url_parse_partial_links($match) {
}
/**
* preg_replace callback to escape contents of HTML comments
* Escapes the contents of HTML comments.
*
* Callback for preg_replace_callback() within _filter_url().
*
* @param $match
* An array containing matches to replace from preg_replace_callback(),
* whereas $match[1] is expected to contain the content to be filtered.
* @param $escape
* (optional) Boolean whether to escape (TRUE) or unescape comments (FALSE).
* Defaults to neither. If TRUE, statically cached $comments are reset.
* (optional) A Boolean indicating whether to escape (TRUE) or unescape
* comments (FALSE). Defaults to NULL, indicating neither. If TRUE, statically
* cached $comments are reset.
*/
function _filter_url_escape_comments($match, $escape = NULL) {
static $mode, $comments = array();
@@ -1582,21 +1655,30 @@ function _filter_url_trim($text, $length = NULL) {
}
/**
* Filter tips callback for URL filter.
* Implements callback_filter_tips().
*
* Provides help for the URL filter.
*
* @see filter_filter_info()
*/
function _filter_url_tips($filter, $format, $long = FALSE) {
return t('Web page addresses and e-mail addresses turn into links automatically.');
}
/**
* Scan input and make sure that all HTML tags are properly closed and nested.
* Implements callback_filter_process().
*
* Scans the input and makes sure that HTML tags are properly closed.
*/
function _filter_htmlcorrector($text) {
return filter_dom_serialize(filter_dom_load($text));
}
/**
* Convert line breaks into <p> and <br> in an intelligent fashion.
* Implements callback_filter_process().
*
* Converts line breaks into <p> and <br> in an intelligent fashion.
*
* Based on: http://photomatt.net/scripts/autop
*/
function _filter_autop($text) {
@@ -1662,7 +1744,11 @@ function _filter_autop($text) {
}
/**
* Filter tips callback for auto-paragraph filter.
* Implements callback_filter_tips().
*
* Provides help for the auto-paragraph filter.
*
* @see filter_filter_info()
*/
function _filter_autop_tips($filter, $format, $long = FALSE) {
if ($long) {
@@ -1674,6 +1760,8 @@ function _filter_autop_tips($filter, $format, $long = FALSE) {
}
/**
* Implements callback_filter_process().
*
* Escapes all HTML tags, so they will be visible instead of being effective.
*/
function _filter_html_escape($text) {
@@ -1681,7 +1769,11 @@ function _filter_html_escape($text) {
}
/**
* Filter tips callback for HTML escaping filter.
* Implements callback_filter_tips().
*
* Provides help for the HTML escaping filter.
*
* @see filter_filter_info()
*/
function _filter_html_escape_tips($filter, $format, $long = FALSE) {
return t('No HTML tags allowed.');

View File

@@ -2,12 +2,17 @@
/**
* @file
* User page callbacks for the filter module.
* User page callbacks for the Filter module.
*/
/**
* Menu callback; show a page with long filter tips.
* Page callback: Displays a page with long filter tips.
*
* @return string
* An HTML-formatted string.
*
* @see filter_menu()
* @see theme_filter_tips()
*/
function filter_tips_long() {
$format_id = arg(2);
@@ -20,13 +25,12 @@ function filter_tips_long() {
return $output;
}
/**
* Returns HTML for a set of filter tips.
*
* @param $variables
* An associative array containing:
* - tips: An array containing descriptions and a CSS id in the form of
* - tips: An array containing descriptions and a CSS ID in the form of
* 'module-name/filter-id' (only used when $long is TRUE) for each
* filter in one or more text formats. Example:
* @code
@@ -64,7 +68,7 @@ function theme_filter_tips($variables) {
foreach ($tips as $name => $tiplist) {
if ($multiple) {
$output .= '<div class="filter-type filter-' . drupal_html_class($name) . '">';
$output .= '<h3>' . $name . '</h3>';
$output .= '<h3>' . check_plain($name) . '</h3>';
}
if (count($tiplist) > 0) {

File diff suppressed because it is too large Load Diff