Skip to content

Commit aeeba0f

Browse files
Add notes about unsafe PARSE_* flags for yaml
1 parent ffb2689 commit aeeba0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/yaml.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ representation of the object.
239239
parsers will likely not recognize the ``php/object`` tag and non-PHP
240240
implementations certainly won't - use with discretion!
241241

242+
.. danger::
243+
244+
Parsing ``!php/object`` tags uses PHP deserialization internally. Never
245+
enable ``PARSE_OBJECT`` for untrusted YAML contents.
246+
242247
Parsing and Dumping Objects as Maps
243248
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244249

@@ -324,6 +329,11 @@ syntax to parse them as proper PHP constants::
324329
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
325330
// $parameters = ['foo' => 'PHP_INT_SIZE', 'bar' => 8];
326331

332+
.. warning::
333+
334+
Enabling ``PARSE_CONSTANT`` allows YAML contents to resolve arbitrary PHP
335+
constants and enum cases. Only enable it for trusted input.
336+
327337
Parsing PHP Enumerations
328338
~~~~~~~~~~~~~~~~~~~~~~~~
329339

0 commit comments

Comments
 (0)