Loading html_title.module +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ function html_title_preprocess_page_title(&$variables) { } /** * Implement hook_preprocess_search_result(). * Implements hook_preprocess_search_result(). */ function html_title_preprocess_search_result(&$variables) { if (isset($variables['result']['node']) && $variables['result']['node'] instanceof NodeInterface) { Loading src/Form/HtmlTitleSettingConfigForm.php +0 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ use Drupal\Core\Form\FormStateInterface; */ class HtmlTitleSettingConfigForm extends ConfigFormBase { protected static $allowHtmlTags = ['<br', '<sub>', '<sup>']; /** * {@inheritdoc} */ Loading src/HtmlTitleFilter.php +14 −11 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ namespace Drupal\html_title; /** * @file * Contains \Drupal\html_title\HtmlTitleFilter. */ use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Html; use Drupal\Core\Config\ConfigFactoryInterface; Loading @@ -17,10 +12,18 @@ use Drupal\Core\Render\Markup; */ class HtmlTitleFilter { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * Construct. * HtmlTitleFilter constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ public function __construct(ConfigFactoryInterface $configFactory) { $this->configFactory = $configFactory; Loading @@ -29,11 +32,11 @@ class HtmlTitleFilter { /** * Helper function to help filter out unwanted XSS opportunities. * * Use this function if you expect to have junk or incomplete html. It uses the * same strategy as the "Fix Html" filter option in configuring the HTML * Use this function if you expect to have junk or incomplete html. It uses * the same strategy as the "Fix Html" filter option in configuring the HTML * filter in the text format configuration. */ protected function filterXSS($title) { protected function filterXss($title) { $dom = new \DOMDocument(); // Ignore warnings during HTML soup loading. @$dom->loadHTML('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $title . '</body></html>', LIBXML_NOENT); Loading @@ -56,7 +59,7 @@ class HtmlTitleFilter { * Filte string with allow html tags. */ public function decodeToText($str) { return $this->filterXSS(Html::decodeEntities((string) $str)); return $this->filterXss(Html::decodeEntities((string) $str)); } /** Loading src/Plugin/views/field/NodeHtmlTitle.php +1 −6 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ namespace Drupal\html_title\Plugin\views\field; /** * @file * Contains \Drupal\html_title\Plugin\views\field\NodeHtmlTitle. */ use Drupal\node\Plugin\views\field\Node; use Drupal\views\ResultRow; Loading tests/modules/html_title_test/html_title_test.module +7 −2 Original line number Diff line number Diff line <?php /** * @file * Support module for the HTML Title module tests. */ use Drupal\Core\Breadcrumb\Breadcrumb; use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; Loading @@ -7,9 +12,9 @@ use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_system_breadcrumb_alter(). */ function html_title_test_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) { function html_title_test_system_breadcrumb_alter(Breadcrumb $breadcrumb, RouteMatchInterface $route_match, array $context) { // Append the current page title to the breadcrumb for non-admin routes. if ($breadcrumb && !\Drupal::service('router.admin_context')->isAdminRoute()) { if (!\Drupal::service('router.admin_context')->isAdminRoute()) { $title = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route_match->getRouteObject()); if (!empty($title)) { $breadcrumb->addLink(Link::createFromRoute($title, '<none>')); Loading Loading
html_title.module +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ function html_title_preprocess_page_title(&$variables) { } /** * Implement hook_preprocess_search_result(). * Implements hook_preprocess_search_result(). */ function html_title_preprocess_search_result(&$variables) { if (isset($variables['result']['node']) && $variables['result']['node'] instanceof NodeInterface) { Loading
src/Form/HtmlTitleSettingConfigForm.php +0 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ use Drupal\Core\Form\FormStateInterface; */ class HtmlTitleSettingConfigForm extends ConfigFormBase { protected static $allowHtmlTags = ['<br', '<sub>', '<sup>']; /** * {@inheritdoc} */ Loading
src/HtmlTitleFilter.php +14 −11 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ namespace Drupal\html_title; /** * @file * Contains \Drupal\html_title\HtmlTitleFilter. */ use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Html; use Drupal\Core\Config\ConfigFactoryInterface; Loading @@ -17,10 +12,18 @@ use Drupal\Core\Render\Markup; */ class HtmlTitleFilter { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * Construct. * HtmlTitleFilter constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ public function __construct(ConfigFactoryInterface $configFactory) { $this->configFactory = $configFactory; Loading @@ -29,11 +32,11 @@ class HtmlTitleFilter { /** * Helper function to help filter out unwanted XSS opportunities. * * Use this function if you expect to have junk or incomplete html. It uses the * same strategy as the "Fix Html" filter option in configuring the HTML * Use this function if you expect to have junk or incomplete html. It uses * the same strategy as the "Fix Html" filter option in configuring the HTML * filter in the text format configuration. */ protected function filterXSS($title) { protected function filterXss($title) { $dom = new \DOMDocument(); // Ignore warnings during HTML soup loading. @$dom->loadHTML('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $title . '</body></html>', LIBXML_NOENT); Loading @@ -56,7 +59,7 @@ class HtmlTitleFilter { * Filte string with allow html tags. */ public function decodeToText($str) { return $this->filterXSS(Html::decodeEntities((string) $str)); return $this->filterXss(Html::decodeEntities((string) $str)); } /** Loading
src/Plugin/views/field/NodeHtmlTitle.php +1 −6 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ namespace Drupal\html_title\Plugin\views\field; /** * @file * Contains \Drupal\html_title\Plugin\views\field\NodeHtmlTitle. */ use Drupal\node\Plugin\views\field\Node; use Drupal\views\ResultRow; Loading
tests/modules/html_title_test/html_title_test.module +7 −2 Original line number Diff line number Diff line <?php /** * @file * Support module for the HTML Title module tests. */ use Drupal\Core\Breadcrumb\Breadcrumb; use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; Loading @@ -7,9 +12,9 @@ use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_system_breadcrumb_alter(). */ function html_title_test_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) { function html_title_test_system_breadcrumb_alter(Breadcrumb $breadcrumb, RouteMatchInterface $route_match, array $context) { // Append the current page title to the breadcrumb for non-admin routes. if ($breadcrumb && !\Drupal::service('router.admin_context')->isAdminRoute()) { if (!\Drupal::service('router.admin_context')->isAdminRoute()) { $title = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route_match->getRouteObject()); if (!empty($title)) { $breadcrumb->addLink(Link::createFromRoute($title, '<none>')); Loading