diff --git a/composer.json b/composer.json
index 813db5f..9f7ba69 100755
--- a/composer.json
+++ b/composer.json
@@ -19,14 +19,14 @@
],
"require": {
"php": ">=5.6.4",
- "illuminate/http": "5.3.*",
- "illuminate/routing": "5.3.*",
- "illuminate/session": "5.3.*",
- "illuminate/support": "5.3.*",
- "illuminate/view": "5.3.*"
+ "illuminate/http": "5.5.*",
+ "illuminate/routing": "5.5.*",
+ "illuminate/session": "5.5.*",
+ "illuminate/support": "5.5.*",
+ "illuminate/view": "5.5.*"
},
"require-dev": {
- "illuminate/database": "5.3.*",
+ "illuminate/database": "5.5.*",
"mockery/mockery": "~0.9.4",
"phpunit/phpunit": "~5.4"
},
@@ -37,5 +37,11 @@
"files": [
"src/helpers.php"
]
- }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.5-dev"
+ }
+ },
+ "minimum-stability": "dev"
}
diff --git a/src/FormBuilder.php b/src/FormBuilder.php
index 4e7cf0f..b10b808 100644
--- a/src/FormBuilder.php
+++ b/src/FormBuilder.php
@@ -7,7 +7,7 @@ use BadMethodCallException;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Contracts\View\Factory;
-use Illuminate\Session\SessionInterface;
+use Illuminate\Contracts\Session\Session;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Routing\UrlGenerator;
@@ -49,7 +49,7 @@ class FormBuilder
/**
* The session store implementation.
*
- * @var \Illuminate\Session\SessionInterface
+ * @var \Illuminate\Contracts\Session\Session
*/
protected $session;
@@ -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('');
+ return $this->toHtmlString('');
}
/**
@@ -662,7 +662,7 @@ class FormBuilder
$html[] = $this->option($display, $value, $selected);
}
- return $this->toHtmlString('');
+ return $this->toHtmlString('');
}
/**
@@ -680,7 +680,7 @@ class FormBuilder
$options = ['value' => $value, 'selected' => $selected];
- return $this->toHtmlString('');
+ return $this->toHtmlString('');
}
/**
@@ -698,7 +698,7 @@ class FormBuilder
$options = compact('selected');
$options['value'] = '';
- return $this->toHtmlString('');
+ return $this->toHtmlString('');
}
/**
@@ -1164,7 +1164,7 @@ class FormBuilder
/**
* Get the session store implementation.
*
- * @return \Illuminate\Session\SessionInterface $session
+ * @return \Illuminate\Contracts\Session\Session $session
*/
public function getSessionStore()
{
@@ -1174,11 +1174,11 @@ class FormBuilder
/**
* Set the session store implementation.
*
- * @param \Illuminate\Session\SessionInterface $session
+ * @param \Illuminate\Contracts\Session\Session $session
*
* @return $this
*/
- public function setSessionStore(SessionInterface $session)
+ public function setSessionStore(Session $session)
{
$this->session = $session;
diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php
index 7306fc4..e6bc518 100755
--- a/src/HtmlBuilder.php
+++ b/src/HtmlBuilder.php
@@ -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 '
' . e($value) . '';
+ return '' . $this->escapeAll($value) . '';
}
}
@@ -449,7 +461,7 @@ class HtmlBuilder
}
if (! is_null($value)) {
- return $key . '="' . e($value) . '"';
+ return $key . '="' . $this->escapeAll($value) . '"';
}
}
diff --git a/tests/FormBuilderTest.php b/tests/FormBuilderTest.php
index 3e4eaad..ff7b37e 100644
--- a/tests/FormBuilderTest.php
+++ b/tests/FormBuilderTest.php
@@ -78,7 +78,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testPasswordsNotFilled()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->never();
@@ -89,7 +89,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFilesNotFilled()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->never();
@@ -113,7 +113,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFormTextRepopulation()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$this->setModel($model = ['relation' => ['key' => 'attribute'], 'other' => 'val']);
$session->shouldReceive('getOldInput')->twice()->with('name_with_dots')->andReturn('some value');
@@ -239,11 +239,13 @@ 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('', $form1);
$this->assertEquals('', $form2);
$this->assertEquals('', $form3);
$this->assertEquals('', $form4);
+ $this->assertEquals('', $form5);
}
public function testSelect()
@@ -301,12 +303,23 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
$select,
''
);
+
+ $select = $this->formBuilder->select(
+ 'encoded_html',
+ ['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
+ null
+ );
+
+ $this->assertEquals(
+ $select,
+ ''
+ );
}
public function testFormSelectRepopulation()
{
$list = ['L' => 'Large', 'M' => 'Medium', 'S' => 'Small'];
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$this->setModel($model = ['size' => ['key' => 'S'], 'other' => 'val']);
$session->shouldReceive('getOldInput')->twice()->with('size')->andReturn('M');
@@ -344,6 +357,16 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
);
$this->assertEquals($select,
'');
+
+ $select = $this->formBuilder->select(
+ 'encoded_html',
+ ['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
+ null,
+ ['placeholder' => 'Select the ']
+ );
+ $this->assertEquals($select,
+ ''
+ );
}
public function testFormSelectYear()
@@ -382,7 +405,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFormCheckbox()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->withNoArgs()->andReturn([]);
$session->shouldReceive('getOldInput')->with('foo')->andReturn(null);
@@ -400,7 +423,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFormCheckboxRepopulation()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->withNoArgs()->andReturn([1]);
$session->shouldReceive('getOldInput')->once()->with('check')->andReturn(null);
@@ -423,7 +446,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFormCheckboxWithModelRelation()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->withNoArgs()->andReturn([]);
$session->shouldReceive('getOldInput')->with('items')->andReturn(null);
@@ -468,7 +491,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
public function testFormRadioRepopulation()
{
- $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
+ $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
$session->shouldReceive('getOldInput')->with('radio')->andReturn(1);
diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php
index 44baeb8..747c89a 100644
--- a/tests/HtmlBuilderTest.php
+++ b/tests/HtmlBuilderTest.php
@@ -39,6 +39,28 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('- foo
- bar
- bing
- baz
', $result);
}
+ public function testOl()
+ {
+ $list = ['foo', 'bar', '&'];
+
+ $attributes = ['class' => 'example'];
+
+ $ol = $this->htmlBuilder->ol($list, $attributes);
+
+ $this->assertEquals('- foo
- bar
- &
', $ol);
+ }
+
+ public function testUl()
+ {
+ $list = ['foo', 'bar', '&'];
+
+ $attributes = ['class' => 'example'];
+
+ $ul = $this->htmlBuilder->ul($list, $attributes);
+
+ $this->assertEquals('', $ul);
+ }
+
public function testMeta()
{
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
@@ -58,7 +80,7 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
$this->htmlBuilder->image('http://example.com/image1'),
$this->htmlBuilder->image('http://example.com/image2'),
];
-
+
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
$this->assertEquals('' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '
' . PHP_EOL, $result1);