Merge pull request #258 from StefanPrintezis/htmlentities_encoding
Values are now encoded consistently by the formbuilder and the htmlbuilder
This commit is contained in:
commit
2f7f2e127c
4 files changed
+65
-8
No files matched your search
+4
-4
@@ -485,7 +485,7 @@ class FormBuilder
|
||||
// the element. Then we'll create the final textarea elements HTML for us.
|
||||
$options = $this->html->attributes($options);
|
||||
|
||||
return $this->toHtmlString('<textarea' . $options . '>' . e($value) . '</textarea>');
|
||||
return $this->toHtmlString('<textarea' . $options . '>' . $this->html->escapeAll($value). '</textarea>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,7 +662,7 @@ class FormBuilder
|
||||
$html[] = $this->option($display, $value, $selected);
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<optgroup label="' . e($label) . '">' . implode('', $html) . '</optgroup>');
|
||||
return $this->toHtmlString('<optgroup label="' . $this->html->escapeAll($label) . '">' . implode('', $html) . '</optgroup>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -680,7 +680,7 @@ class FormBuilder
|
||||
|
||||
$options = ['value' => $value, 'selected' => $selected];
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . $this->html->escapeAll($display) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -698,7 +698,7 @@ class FormBuilder
|
||||
$options = compact('selected');
|
||||
$options['value'] = '';
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . $this->html->escapeAll($display) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+15
-3
@@ -53,6 +53,18 @@ class HtmlBuilder
|
||||
return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert all applicable characters to HTML entities.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeAll($value)
|
||||
{
|
||||
return htmlentities($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert entities to HTML characters.
|
||||
*
|
||||
@@ -288,7 +300,7 @@ class HtmlBuilder
|
||||
{
|
||||
return str_repeat(' ', $num);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate an ordered list of items.
|
||||
*
|
||||
@@ -387,7 +399,7 @@ class HtmlBuilder
|
||||
if (is_array($value)) {
|
||||
return $this->nestedListing($key, $type, $value);
|
||||
} else {
|
||||
return '<li>' . e($value) . '</li>';
|
||||
return '<li>' . $this->escapeAll($value) . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +461,7 @@ class HtmlBuilder
|
||||
}
|
||||
|
||||
if (! is_null($value)) {
|
||||
return $key . '="' . e($value) . '"';
|
||||
return $key . '="' . $this->escapeAll($value) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user