Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / filter / filter.module
index e3095346ddaa8875230d916e9bd9e1c09ee04d4d..e1d3657574f85e86e8bedf770413aaa90d2b5204 100644 (file)
@@ -74,7 +74,7 @@ function filter_theme() {
         'caption' => NULL,
         'classes' => NULL,
       ],
-    ]
+    ],
   ];
 }
 
@@ -287,7 +287,7 @@ function filter_fallback_format() {
  * @return \Drupal\Component\Render\MarkupInterface
  *   The filtered text.
  *
- * @see filter_process_text()
+ * @see \Drupal\filter\Plugin\FilterInterface::process()
  *
  * @ingroup sanitization
  */
@@ -496,8 +496,8 @@ function _filter_url($text, $filter) {
   $valid_url_query_chars = '[a-zA-Z0-9!?\*\'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]';
   $valid_url_query_ending_chars = '[a-zA-Z0-9_&=#\/]';
 
-  //full path
-  //and allow @ in a url, but only in the middle. Catch things like http://example.com/@user/
+  // full path
+  // and allow @ in a url, but only in the middle. Catch things like http://example.com/@user/
   $valid_url_path = '(?:(?:' . $valid_url_path_characters . '*(?:' . $valid_url_balanced_parens . $valid_url_path_characters . '*)*' . $valid_url_ending_characters . ')|(?:@' . $valid_url_path_characters . '+\/))';
 
   // Prepare domain name pattern.
@@ -729,20 +729,28 @@ function _filter_autop($text) {
       }
     }
     elseif (!$ignore) {
-      $chunk = preg_replace('|\n*$|', '', $chunk) . "\n\n"; // just to make things a little easier, pad the end
+      // just to make things a little easier, pad the end
+      $chunk = preg_replace('|\n*$|', '', $chunk) . "\n\n";
       $chunk = preg_replace('|<br />\s*<br />|', "\n\n", $chunk);
-      $chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk); // Space things out a little
-      $chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk); // Space things out a little
-      $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates
+      // Space things out a little
+      $chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk);
+      // Space things out a little
+      $chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk);
+      // take care of duplicates
+      $chunk = preg_replace("/\n\n+/", "\n\n", $chunk);
       $chunk = preg_replace('/^\n|\n\s*\n$/', '', $chunk);
-      $chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n"; // make paragraphs, including one at the end
-      $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
+      // make paragraphs, including one at the end
+      $chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n";
+      // problem with nested lists
+      $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk);
       $chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
       $chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk);
-      $chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
+      // under certain strange conditions it could create a P of entirely whitespace
+      $chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk);
       $chunk = preg_replace('!<p>\s*(</?' . $block . '[^>]*>)!', "$1", $chunk);
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk);
-      $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
+      // make line breaks
+      $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk);
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*<br />!', "$1", $chunk);
       $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $chunk);
       $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
@@ -765,7 +773,7 @@ function _filter_html_escape($text) {
 function _filter_html_image_secure_process($text) {
   // Find the path (e.g. '/') to Drupal root.
   $base_path = base_path();
-  $base_path_length = Unicode::strlen($base_path);
+  $base_path_length = mb_strlen($base_path);
 
   // Find the directory on the server where index.php resides.
   $local_dir = \Drupal::root() . '/';
@@ -781,11 +789,11 @@ function _filter_html_image_secure_process($text) {
     // Verify that $src starts with $base_path.
     // This also ensures that external images cannot be referenced.
     $src = $image->getAttribute('src');
-    if (Unicode::substr($src, 0, $base_path_length) === $base_path) {
+    if (mb_substr($src, 0, $base_path_length) === $base_path) {
       // Remove the $base_path to get the path relative to the Drupal root.
       // Ensure the path refers to an actual image by prefixing the image source
       // with the Drupal root and running getimagesize() on it.
-      $local_image_path = $local_dir . Unicode::substr($src, $base_path_length);
+      $local_image_path = $local_dir . mb_substr($src, $base_path_length);
       $local_image_path = rawurldecode($local_image_path);
       if (@getimagesize($local_image_path)) {
         // The image has the right path. Erroneous images are dealt with below.