Problem/Motivation

See parent issue.

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new28.98 KB

Status: Needs review » Needs work

The last submitted patch, 1: filter-2326881-1.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new29.25 KB

Rerolled for now without the hook_element_info() removal in light of #2326409: Annotate render element plugins

Status: Needs review » Needs work

The last submitted patch, 3: 2326881-filter-3.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new29.38 KB
new1 KB
jibran’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/filter/src/Element/ProcessedText.php
    @@ -0,0 +1,154 @@
    +   * 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
    ...
    +   *     array (default) to skip no filter types. All of the format's filters will
    +   *     be applied, except for filters of the types that are marked to be skipped.
    ...
    +    // Give filters the chance to escape HTML-like data such as code or formulas.
    
    +++ b/core/modules/filter/src/Element/TextFormat.php
    @@ -0,0 +1,232 @@
    +   *   using the text format ID specified in #format or the user's default format
    ...
    +   *     available for this element. If omitted, all text formats that the current
    ...
    +    // If #allowed_formats is set, the list of formats must not be modified in any
    ...
    +    // 1. The 'always_show_fallback_choice' filter setting has not been activated.
    ...
    +    // or if the stored format does not exist. The 'administer filters' permission
    

    More then 80 chars.

  2. +++ b/core/modules/filter/src/Element/ProcessedText.php
    @@ -0,0 +1,154 @@
    +      $format_id = filter_fallback_format();
    

    We can use \Drupal::config('filter.settings')->get('fallback_format'); here.

  3. +++ b/core/modules/filter/src/Element/ProcessedText.php
    @@ -0,0 +1,154 @@
    +      \Drupal::logger('filter')->alert('Missing text format: %format.', array('%format' => $format_id));
    
    +++ b/core/modules/filter/src/Element/TextFormat.php
    @@ -0,0 +1,232 @@
    +    $user = \Drupal::currentUser();
    ...
    +    $element['value'] += \Drupal::service('element_info')->getInfo($element['#base_type']);
    ...
    +    if (!isset($element['#allowed_formats']) && !\Drupal::config('filter.settings')->get('always_show_fallback_choice')) {
    ...
    +    $user_is_admin = \Drupal::currentUser()->hasPermission('administer filters');
    

    We can inject these.

  4. +++ b/core/modules/filter/src/Element/ProcessedText.php
    @@ -0,0 +1,154 @@
    +    /** @var \Drupal\filter\FilterBag $filters **/
    ...
    +    /** @var \Drupal\filter\Plugin\FilterInterface $filter **/
    

    I don't think we need this.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new30.32 KB
new10.03 KB
jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for the fixes.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed 2c1fe04 on 8.0.x
    Issue #2326881 by tim.plunkett: Convert filter_element_info() to Element...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.