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:
Flavio Copes
2017-05-17 19:42:27 +02:00
committed by Andy Miller
parent 5c0d378d1e
commit 8dabe88246

View File

@@ -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.