only in patch2: unchanged: --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -130,7 +130,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana * (optional) Language code to translate to. NULL (default) means to use * the user interface language for the page. * - * @return string + * @return \Drupal\Core\Datetime\DateString * A translated date string in the requested format. */ public function format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { @@ -168,7 +168,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N $settings = array( 'langcode' => $langcode, ); - return Xss::filter($date->format($format, $settings)); + return $date->format($format, $settings); } /** only in patch2: unchanged: --- /dev/null +++ b/core/lib/Drupal/Core/Datetime/DateString.php @@ -0,0 +1,37 @@ +string); + } + +} only in patch2: unchanged: --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -89,8 +89,8 @@ protected function prepareTimezone($timezone) { * - langcode: (optional) String two letter language code used to control * the result of the format() method. Defaults to NULL. * - * @return string - * The formatted value of the date. + * @return \Drupal\Core\Datetime\DateString + * A date string in the requested format. */ public function format($format, $settings = array()) { $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode; @@ -134,7 +134,7 @@ public function format($format, $settings = array()) { catch (\Exception $e) { $this->errors[] = $e->getMessage(); } - return $value; + return DateString::create($value); } } only in patch2: unchanged: --- a/core/modules/system/src/Tests/System/DateTimeTest.php +++ b/core/modules/system/src/Tests/System/DateTimeTest.php @@ -133,6 +133,21 @@ function testDateFormatConfiguration() { $this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.'); $this->assertText($name, 'Custom date format appears in the date format list.'); $this->assertText(t('Delete'), 'Delete link for custom date format appears.'); + + // Add a new date format with HTML in it. + $date_format_id = strtolower($this->randomMachineName(8)); + $name = ucwords($date_format_id); + $date_format = '& \<\e\m\>Y\<\/\e\m\>'; + $edit = array( + 'id' => $date_format_id, + 'label' => $name, + 'date_format_pattern' => $date_format, + ); + $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format')); + $this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); + $this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.'); + $this->assertText($name, 'Custom date format appears in the date format list.'); + $this->assertRaw('& ' . date("Y") . ''); } /**