Commit 4ea130a5 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1832803: Check for empty string before passing it to DOMDocument"

parents 9dc6e7de 323d7493
......@@ -1172,12 +1172,15 @@ class ArtefactTypeComment extends ArtefactType {
/*
* Removes the classes from the text of the comment thst could interfere
* Removes the classes from the text of the comment that could interfere
* with the comment display
* @param string $comment the text content of the comment
*/
public static function remove_comments_classes($comment) {
if (empty($comment)) {
return "";
}
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
......
......@@ -380,15 +380,17 @@ class BehatDataGenerators extends BehatBase {
* @param array ('field' => 'values', ...) $record
* @return $record
*/
public function normalise(&$record) {
foreach ($record as &$value) {
$value = trim($value);
// Normalise boolean values
if (strtolower($value) == 'on' || $value == '1' || $value == 'true') {
$value = true;
}
else if (strtolower($value) == 'off' || $value == '0' || $value == 'false') {
$value = false;
public function normalise($availablefields, &$record) {
foreach ($record as $fieldname => &$value) {
if ($availablefields[$fieldname] == 'bool') {
$value = trim($value);
// Normalise boolean values
if (strtolower($value) == 'on' || $value == '1' || $value == 'yes' || $value == 'true') {
$value = true;
}
else if (strtolower($value) == 'off' || $value == '0' || $value == 'no' || $value == 'false') {
$value = false;
}
}
}
}
......@@ -447,7 +449,7 @@ class BehatDataGenerators extends BehatBase {
foreach ($data->getHash() as $elementdata) {
// Normalise field values
$this->normalise($elementdata);
$this->normalise($availablefields, $elementdata);
// Validate available fields for given element
$this->validate_fields($availablefields, $elementdata);
// Check if all the required fields are there.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment