diff --git a/core/modules/block/block.links.action.yml b/core/modules/block/block.links.action.yml index 2e6534d..2340747 100644 --- a/core/modules/block/block.links.action.yml +++ b/core/modules/block/block.links.action.yml @@ -1,10 +1,10 @@ block_layout_add_action: - route_name: block.admin_layout + route_name: block.admin_library title: 'Add block to layout' appears_on: - block.admin_display block_layout_add_action_for_theme: - route_name: block.admin_layout_theme + route_name: block.admin_library_theme title: 'Add block to layout' appears_on: - block.admin_display_theme diff --git a/core/modules/block/block.links.task.yml b/core/modules/block/block.links.task.yml index c3ff5f3..123dd4c 100644 --- a/core/modules/block/block.links.task.yml +++ b/core/modules/block/block.links.task.yml @@ -15,12 +15,10 @@ block.admin_display_theme: deriver: 'Drupal\block\Plugin\Derivative\ThemeLocalTask' # Per theme block placement pages. -block.admin_layout: - title: 'Add block to layout' - route_name: block.admin_layout - base_route: block.admin_layout -block.admin_layout_theme: - title: 'Add block to layout' - route_name: block.admin_layout_theme - parent_id: block.admin_layout +block.admin_library: + route_name: block.admin_library + base_route: block.admin_library +block.admin_library_theme: + route_name: block.admin_library_theme + parent_id: block.admin_library deriver: 'Drupal\block\Plugin\Derivative\ThemeLocalTask' diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index 02d416a..0ccab2b 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -42,18 +42,18 @@ block.admin_display_theme: _access_theme: 'TRUE' _permission: 'administer blocks' -block.admin_layout: - path: 'admin/structure/block/layout' +block.admin_library: + path: 'admin/structure/block/library' defaults: - _controller: '\Drupal\block\Controller\BlockLayoutListController::layout' + _controller: '\Drupal\block\Controller\BlockLibraryController::listBlocks' _title: 'Add block to layout' requirements: _permission: 'administer blocks' -block.admin_layout_theme: - path: 'admin/structure/block/layout/{theme}' +block.admin_library_theme: + path: 'admin/structure/block/library/{theme}' defaults: - _controller: '\Drupal\block\Controller\BlockLayoutListController::layout' + _controller: '\Drupal\block\Controller\BlockLibraryController::listBlocks' _title: 'Add block to layout' requirements: _access_theme: 'TRUE' diff --git a/core/modules/block/src/Controller/BlockLayoutListController.php b/core/modules/block/src/Controller/BlockLibraryController.php similarity index 89% rename from core/modules/block/src/Controller/BlockLayoutListController.php rename to core/modules/block/src/Controller/BlockLibraryController.php index 541dc27..703089c 100644 --- a/core/modules/block/src/Controller/BlockLayoutListController.php +++ b/core/modules/block/src/Controller/BlockLibraryController.php @@ -2,11 +2,12 @@ /** * @file - * Contains \Drupal\block\Controller\BlockLayoutListController. + * Contains \Drupal\block\Controller\BlockLibraryController. */ namespace Drupal\block\Controller; +use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; @@ -15,7 +16,7 @@ /** * Provides a list of block plugins to be added to the layout. */ -class BlockLayoutListController extends ControllerBase { +class BlockLibraryController extends ControllerBase { /** * The block manager. @@ -25,7 +26,7 @@ class BlockLayoutListController extends ControllerBase { protected $blockManager; /** - * Constructs a BlockListController object. + * Constructs a BlockLibraryController object. * * @param \Drupal\Core\Block\BlockManagerInterface $block_manager * The block manager. @@ -52,7 +53,7 @@ public static function create(ContainerInterface $container) { * @return array * A render array as expected by the renderer. */ - public function layout($theme = NULL) { + public function listBlocks($theme = NULL) { $theme = $theme ?: $this->config('system.theme')->get('default'); $headers = [ @@ -74,7 +75,7 @@ public function layout($theme = NULL) { '#prefix' => '
', '#suffix' => '
', ]; - $row['category']['data'] = $plugin_definition['category']; + $row['category']['data'] = SafeMarkup::checkPlain($plugin_definition['category']); $links['add'] = [ 'title' => $this->t('Add block'), 'url' => Url::fromRoute('block.admin_add', ['plugin_id' => $plugin_id, 'theme' => $theme]), @@ -113,4 +114,5 @@ public function layout($theme = NULL) { return $build; } + } diff --git a/core/modules/block/src/Controller/BlockListController.php b/core/modules/block/src/Controller/BlockListController.php index b10e86f..72aa445 100644 --- a/core/modules/block/src/Controller/BlockListController.php +++ b/core/modules/block/src/Controller/BlockListController.php @@ -7,10 +7,7 @@ namespace Drupal\block\Controller; -use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Entity\Controller\EntityListController; -use Drupal\Core\Url; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; /** diff --git a/core/modules/block/src/Tests/BlockLanguageCacheTest.php b/core/modules/block/src/Tests/BlockLanguageCacheTest.php index 7c3f52e..c07731d 100644 --- a/core/modules/block/src/Tests/BlockLanguageCacheTest.php +++ b/core/modules/block/src/Tests/BlockLanguageCacheTest.php @@ -8,6 +8,7 @@ namespace Drupal\block\Tests; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\simpletest\WebTestBase; @@ -59,9 +60,10 @@ public function testBlockLinks() { )); $this->drupalLogin($admin_user); + $url = Url::fromRoute('block.admin_library'); // Create the block cache for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet('admin/structure/block/layout', array('language' => $langcode)); + $this->drupalGet($url, array('language' => $langcode)); } // Create a menu in the default language. @@ -72,7 +74,7 @@ public function testBlockLinks() { // Check that the block is listed for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet('admin/structure/block/layout', array('language' => $langcode)); + $this->drupalGet($url, array('language' => $langcode)); $this->assertText($edit['label']); } } diff --git a/core/modules/block/src/Tests/BlockTitleXSSTest.php b/core/modules/block/src/Tests/BlockTitleXSSTest.php deleted file mode 100644 index 3790d56..0000000 --- a/core/modules/block/src/Tests/BlockTitleXSSTest.php +++ /dev/null @@ -1,46 +0,0 @@ -drupalPlaceBlock('test_xss_title', array('label' => '')); - } - - /** - * Test XSS in title. - */ - function testXSSInTitle() { - \Drupal::state()->set('block_test.content', $this->randomMachineName()); - $this->drupalGet(''); - $this->assertNoRaw('', 'The block title was properly sanitized when rendered.'); - - $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'access administration pages'))); - $default_theme = $this->config('system.theme')->get('default'); - $this->drupalGet('admin/structure/block/list/' . $default_theme); - $this->assertNoRaw("", 'The block title was properly sanitized in Block Plugin UI Admin page.'); - } - -} diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index 89eb877..28426f6 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -147,7 +147,7 @@ public function testCandidateBlockList() { $pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]'; // Check if the block is listed. - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the category for its module.'); @@ -156,7 +156,7 @@ public function testCandidateBlockList() { $this->container->get('plugin.manager.block')->clearCachedDefinitions(); // Check if the block is listed with a custom category. - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); $arguments[':category'] = "Custom category"; $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in a custom category controlled by block_test_block_alter().'); diff --git a/core/modules/block/src/Tests/BlockXssTest.php b/core/modules/block/src/Tests/BlockXssTest.php index bb5c699..a6df297 100644 --- a/core/modules/block/src/Tests/BlockXssTest.php +++ b/core/modules/block/src/Tests/BlockXssTest.php @@ -26,7 +26,33 @@ class BlockXssTest extends WebTestBase { * * @var array */ - public static $modules = ['block', 'block_content', 'menu_ui', 'views']; + public static $modules = ['block', 'block_content', 'block_test', 'menu_ui', 'views']; + + /** + * Test XSS in title. + */ + public function _testXSSInTitle() { + $this->drupalPlaceBlock('test_xss_title', array('label' => '')); + + \Drupal::state()->set('block_test.content', $this->randomMachineName()); + $this->drupalGet(''); + $this->assertNoRaw('', 'The block title was properly sanitized when rendered.'); + + $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'access administration pages'))); + $default_theme = $this->config('system.theme')->get('default'); + $this->drupalGet('admin/structure/block/list/' . $default_theme); + $this->assertNoRaw("", 'The block title was properly sanitized in Block Plugin UI Admin page.'); + } + + /** + * Test XSS in title. + */ + public function testXSSInCategory() { + $this->drupalPlaceBlock('test_xss_title'); + $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages'])); + $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->assertNoRaw(""); + } /** * Tests various modules that provide blocks for XSS. @@ -50,7 +76,7 @@ protected function doViewTest() { $view->addDisplay('block'); $view->save(); - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("view");'); $this->assertNoRaw(''); @@ -65,7 +91,7 @@ protected function doMenuTest() { 'label' => '', ])->save(); - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("menu");'); $this->assertNoRaw(''); @@ -85,7 +111,7 @@ protected function doBlockContentTest() { 'info' => '', ])->save(); - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("block_content");'); $this->assertNoRaw(''); diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php index 08c6a54..24dc5c1 100644 --- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php @@ -70,7 +70,7 @@ public function testBlockCategory() { )), ':category' => t('Lists (Views)'), ); - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.'); @@ -94,7 +94,7 @@ public function testBlockCategory() { // Test that the blocks are listed under the correct categories. $arguments[':category'] = $category; - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the custom category.'); diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php index 3146b59..1f028c3 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php @@ -8,10 +8,11 @@ namespace Drupal\block_test\Plugin\Block; /** - * Provides a block to test XSS in title. + * Provides a block to test XSS in the title and category. * * @Block( * id = "test_xss_title", + * category = @Translation(""), * admin_label = "" * ) */ diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php index 2c72178..e2a85fb 100644 --- a/core/modules/menu_ui/src/Tests/MenuTest.php +++ b/core/modules/menu_ui/src/Tests/MenuTest.php @@ -217,7 +217,7 @@ protected function addCustomMenu() { $this->assertText($label, 'Menu created'); // Confirm that the custom menu block is available. - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); $this->assertText($label); // Enable the block. @@ -530,7 +530,7 @@ function testSystemMenuRename() { // Make sure menu shows up with new name in block addition. $default_theme = $this->config('system.theme')->get('default'); - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $default_theme])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $default_theme])); $this->assertText($edit['label']); } diff --git a/core/modules/search/src/Tests/SearchBlockTest.php b/core/modules/search/src/Tests/SearchBlockTest.php index 58f9cc9..e742d91 100644 --- a/core/modules/search/src/Tests/SearchBlockTest.php +++ b/core/modules/search/src/Tests/SearchBlockTest.php @@ -36,7 +36,7 @@ protected function setUp() { public function testSearchFormBlock() { // Test availability of the search block in the admin "Place blocks" list. - $this->drupalGet(Url::fromRoute('block.admin_layout')); + $this->drupalGet(Url::fromRoute('block.admin_library')); $this->assertLinkByHref('/admin/structure/block/add/search_form_block/classy', 0, 'Did not find the search block in block candidate list.'); diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php index c2d72bf..88c767b 100644 --- a/core/modules/views/src/Tests/Wizard/BasicTest.php +++ b/core/modules/views/src/Tests/Wizard/BasicTest.php @@ -132,7 +132,7 @@ function testViewsWizardAndListing() { $this->assertNoText('REST export', 'If only the page and block options were enabled in the wizard, the resulting view does not have a REST export display.'); // Confirm that the block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); $this->assertText($view3['label']); // Place the block. diff --git a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php index 7b94948..ea46eb0 100644 --- a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php @@ -72,7 +72,7 @@ function testItemsPerPage() { $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, 'The nodes appear in the expected order in the page display.'); // Confirm that the block is listed in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); $this->assertText($view['label']); // Place the block, visit a page that displays the block, and check that the diff --git a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php index 16daff8..145542a 100644 --- a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php +++ b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php @@ -51,7 +51,7 @@ function testOverrideDisplays() { $this->assertText($original_title); // Confirm that the view block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); $this->assertText($view['label']); // Place the block. @@ -110,7 +110,7 @@ function testWizardMixedDefaultOverriddenDisplays() { $this->assertNoText($view['block[title]']); // Confirm that the block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_layout_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); $this->assertText($view['label']); // Put the block into the first sidebar region, and make sure it will not diff --git a/interdiff-test-fix.txt b/interdiff-test-fix.txt new file mode 100644 index 0000000..2c874ee --- /dev/null +++ b/interdiff-test-fix.txt @@ -0,0 +1,21 @@ +diff --git a/core/modules/block/src/Controller/BlockLibraryController.php b/core/modules/block/src/Controller/BlockLibraryController.php +index 187fe7b..703089c 100644 +--- a/core/modules/block/src/Controller/BlockLibraryController.php ++++ b/core/modules/block/src/Controller/BlockLibraryController.php +@@ -7,6 +7,7 @@ + + namespace Drupal\block\Controller; + ++use Drupal\Component\Utility\SafeMarkup; + use Drupal\Core\Block\BlockManagerInterface; + use Drupal\Core\Controller\ControllerBase; + use Drupal\Core\Url; +@@ -74,7 +75,7 @@ public function listBlocks($theme = NULL) { + '#prefix' => '
', + '#suffix' => '
', + ]; +- $row['category']['data'] = $plugin_definition['category']; ++ $row['category']['data'] = SafeMarkup::checkPlain($plugin_definition['category']); + $links['add'] = [ + 'title' => $this->t('Add block'), + 'url' => Url::fromRoute('block.admin_add', ['plugin_id' => $plugin_id, 'theme' => $theme]),