class TestXssBlock

Same name and namespace in other branches
  1. 11.x core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXssBlock.php \Drupal\block_test\Plugin\Block\TestXssBlock

Provides a block containing an XSS payload.

Attributes

#[Block(id: "test_xss", admin_label: new TranslatableMarkup("XSS payload"))]

Hierarchy

Expanded class hierarchy of TestXssBlock

File

core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXssBlock.php, line 16

Namespace

Drupal\block_test\Plugin\Block
View source
class TestXssBlock extends BlockBase {
  
  /**
   * {@inheritdoc}
   */
  public function build() : array {
    $payload = '<img src=x onerror="window.XSS = true;">';
    return [
      '#markup' => Markup::create('<input class="block-filter-text" data-element="' . Html::escape($payload) . '">'),
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.