Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Component / Serialization / YamlSymfony.php
index 8818e525345d3a47eb7c701a4e0b61e0b2c5a92a..d35e09cd4821923b63cf2dbe116bbf16ab7cb452 100644 (file)
@@ -5,6 +5,7 @@ namespace Drupal\Component\Serialization;
 use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
 use Symfony\Component\Yaml\Parser;
 use Symfony\Component\Yaml\Dumper;
+use Symfony\Component\Yaml\Yaml as SymfonyYaml;
 
 /**
  * Default serialization for YAML using the Symfony component.
@@ -16,9 +17,9 @@ class YamlSymfony implements SerializationInterface {
    */
   public static function encode($data) {
     try {
-      $yaml = new Dumper();
-      $yaml->setIndentation(2);
-      return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
+      // Set the indentation to 2 to match Drupal's coding standards.
+      $yaml = new Dumper(2);
+      return $yaml->dump($data, PHP_INT_MAX, 0, SymfonyYaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
     }
     catch (\Exception $e) {
       throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
@@ -33,7 +34,7 @@ class YamlSymfony implements SerializationInterface {
       $yaml = new Parser();
       // Make sure we have a single trailing newline. A very simple config like
       // 'foo: bar' with no newline will fail to parse otherwise.
-      return $yaml->parse($raw, TRUE, FALSE);
+      return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
     }
     catch (\Exception $e) {
       throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);