Fixes for escape issue
This commit is contained in:
1 parent
4c4188935e
commit
856e1e6d6b
4 files changed
+6
-63
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 . '>' . $this->html->escapeAll($value). '</textarea>');
|
||||
return $this->toHtmlString('<textarea' . $options . '>' . e($value). '</textarea>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,7 +662,7 @@ class FormBuilder
|
||||
$html[] = $this->option($display, $value, $selected);
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<optgroup label="' . $this->html->escapeAll($label) . '">' . implode('', $html) . '</optgroup>');
|
||||
return $this->toHtmlString('<optgroup label="' . e($label) . '">' . implode('', $html) . '</optgroup>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -680,7 +680,7 @@ class FormBuilder
|
||||
|
||||
$options = ['value' => $value, 'selected' => $selected];
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . $this->html->escapeAll($display) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -698,7 +698,7 @@ class FormBuilder
|
||||
$options = compact('selected');
|
||||
$options['value'] = '';
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . $this->html->escapeAll($display) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-14
@@ -53,18 +53,6 @@ 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.
|
||||
*
|
||||
@@ -399,7 +387,7 @@ class HtmlBuilder
|
||||
if (is_array($value)) {
|
||||
return $this->nestedListing($key, $type, $value);
|
||||
} else {
|
||||
return '<li>' . $this->escapeAll($value) . '</li>';
|
||||
return '<li>' . e($value) . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +449,7 @@ class HtmlBuilder
|
||||
}
|
||||
|
||||
if (! is_null($value)) {
|
||||
return $key . '="' . $this->escapeAll($value) . '"';
|
||||
return $key . '="' . e($value) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,13 +239,11 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$form2 = $this->formBuilder->textarea('foo', 'foobar');
|
||||
$form3 = $this->formBuilder->textarea('foo', null, ['class' => 'span2']);
|
||||
$form4 = $this->formBuilder->textarea('foo', null, ['size' => '60x15']);
|
||||
$form5 = $this->formBuilder->textarea('encoded_html', '&');
|
||||
|
||||
$this->assertEquals('<textarea name="foo" cols="50" rows="10"></textarea>', $form1);
|
||||
$this->assertEquals('<textarea name="foo" cols="50" rows="10">foobar</textarea>', $form2);
|
||||
$this->assertEquals('<textarea class="span2" name="foo" cols="50" rows="10"></textarea>', $form3);
|
||||
$this->assertEquals('<textarea name="foo" cols="60" rows="15"></textarea>', $form4);
|
||||
$this->assertEquals('<textarea name="encoded_html" cols="50" rows="10">&amp;</textarea>', $form5);
|
||||
}
|
||||
|
||||
public function testSelect()
|
||||
@@ -303,17 +301,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$select,
|
||||
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
||||
);
|
||||
|
||||
$select = $this->formBuilder->select(
|
||||
'encoded_html',
|
||||
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
||||
null
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$select,
|
||||
'<select name="encoded_html"><option value="no_break_space">&nbsp;</option><option value="ampersand">&amp;</option><option value="lower_than">&lt;</option></select>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormSelectRepopulation()
|
||||
@@ -357,16 +344,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
$this->assertEquals($select,
|
||||
'<select name="size"><option value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||
|
||||
$select = $this->formBuilder->select(
|
||||
'encoded_html',
|
||||
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
||||
null,
|
||||
['placeholder' => 'Select the ']
|
||||
);
|
||||
$this->assertEquals($select,
|
||||
'<select name="encoded_html"><option selected="selected" value="">Select the &nbsp;</option><option value="no_break_space">&nbsp;</option><option value="ampersand">&amp;</option><option value="lower_than">&lt;</option></select>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormSelectYear()
|
||||
|
||||
@@ -39,28 +39,6 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<dl class="example"><dt>foo</dt><dd>bar</dd><dt>bing</dt><dd>baz</dd></dl>', $result);
|
||||
}
|
||||
|
||||
public function testOl()
|
||||
{
|
||||
$list = ['foo', 'bar', '&'];
|
||||
|
||||
$attributes = ['class' => 'example'];
|
||||
|
||||
$ol = $this->htmlBuilder->ol($list, $attributes);
|
||||
|
||||
$this->assertEquals('<ol class="example"><li>foo</li><li>bar</li><li>&amp;</li></ol>', $ol);
|
||||
}
|
||||
|
||||
public function testUl()
|
||||
{
|
||||
$list = ['foo', 'bar', '&'];
|
||||
|
||||
$attributes = ['class' => 'example'];
|
||||
|
||||
$ul = $this->htmlBuilder->ul($list, $attributes);
|
||||
|
||||
$this->assertEquals('<ul class="example"><li>foo</li><li>bar</li><li>&amp;</li></ul>', $ul);
|
||||
}
|
||||
|
||||
public function testMeta()
|
||||
{
|
||||
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
||||
|
||||
Reference in new issue
Block a user