Commit a88eee68 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3335302 by DamienMcKenna, bsnodgrass, Anna D: Deprecated function:...

Issue #3335302 by DamienMcKenna, bsnodgrass, Anna D: Deprecated function: str_replace() line 432 MetaNameBase.php.
parent b0ec2215
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ Metatag 8.x-1.x-dev, 2022-xx-xx
#3353826 by DamienMcKenna: Add default settings file.
#3325035 by Panchuk: View page meta tags can be overridden by view block that
  placed on same page.
#3335302 by DamienMcKenna, bsnodgrass, Anna D: Deprecated function:
  str_replace() line 432 MetaNameBase.php.


Metatag 8.x-1.22, 2022-09-29
+14 −3
Original line number Diff line number Diff line
@@ -429,6 +429,10 @@ abstract class MetaNameBase extends PluginBase {
   *   The meta tag value after processing.
   */
  protected function tidy($value) {
    if (is_null($value) || $value == '') {
      return '';
    }

    $value = str_replace(["\r\n", "\n", "\r", "\t"], ' ', $value);
    $value = preg_replace('/\s+/', ' ', $value);
    return trim($value);
@@ -441,8 +445,8 @@ abstract class MetaNameBase extends PluginBase {
   *   A render array or an empty string.
   */
  public function output() {
    if (empty($this->value)) {
      // If there is no value, we don't want a tag output.
    // If there is no value, just return either an empty array or empty string.
    if (is_null($this->value) || $this->value == '') {
      return $this->multiple() ? [] : '';
    }

@@ -458,7 +462,7 @@ abstract class MetaNameBase extends PluginBase {
    $elements = [];
    foreach ($values as $value) {
      $value = $this->tidy($value);
      if ($this->requiresAbsoluteUrl()) {
      if ($value != '' && $this->requiresAbsoluteUrl()) {
        // Relative URL.
        if (parse_url($value, PHP_URL_HOST) == NULL) {
          $value = $this->request->getSchemeAndHttpHost() . $value;
@@ -511,6 +515,13 @@ abstract class MetaNameBase extends PluginBase {
  protected function parseImageUrl($value) {
    global $base_root;

    // Skip all logic if the string is empty. Unlike other scenarios, the logic
    // in this method is predicated on the value being a legitimate string, so
    // it's ok to skip all possible "empty" values, including the number 0, etc.
    if (empty($value)) {
      return '';
    }

    // If image tag src is relative (starts with /), convert to an absolute
    // link; ignore protocol-relative URLs.
    $image_tag = FALSE;