mirror of
https://github.com/getgrav/grav.git
synced 2026-07-09 01:42:23 +02:00
Avoid validation on a YAML field, do not parse YAML (#1480)
YAML parsing causes a fatal error if the field is not a string
This commit is contained in:
committed by
Andy Miller
parent
5c0d378d1e
commit
8dabe88246
@@ -38,6 +38,11 @@ class Validation
|
||||
$field['type'] = 'text';
|
||||
}
|
||||
|
||||
// If this is a YAML field, stop validation
|
||||
if (isset($field['yaml']) && $field['yaml'] === true) {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
// Get language class.
|
||||
$language = Grav::instance()['language'];
|
||||
|
||||
@@ -98,13 +103,7 @@ class Validation
|
||||
|
||||
// If this is a YAML field, simply parse it and return the value.
|
||||
if (isset($field['yaml']) && $field['yaml'] === true) {
|
||||
try {
|
||||
$yaml = new Parser();
|
||||
|
||||
return $yaml->parse($value);
|
||||
} catch (ParseException $e) {
|
||||
throw new \RuntimeException($e->getMessage());
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Validate type with fallback type text.
|
||||
|
||||
Reference in New Issue
Block a user