Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
478288d8bc | ||
|
|
86832de708 | ||
|
|
92f3ba71c5 | ||
|
|
8629fe295b | ||
|
|
2f7f2e127c | ||
|
|
f153be5313 | ||
|
|
6d1d46a258 | ||
|
|
df0e112720 | ||
|
|
c1a105975b | ||
|
|
961ce141c1 | ||
|
|
c4c87916c3 |
No files matched your search
+1
-1
@@ -1,9 +1,9 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
|
||||
sudo: false
|
||||
|
||||
+9
-9
@@ -18,17 +18,17 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"illuminate/http": "5.2.*",
|
||||
"illuminate/routing": "5.2.*",
|
||||
"illuminate/session": "5.2.*",
|
||||
"illuminate/support": "5.2.*",
|
||||
"illuminate/view": "5.2.*"
|
||||
"php": ">=5.6.4",
|
||||
"illuminate/http": "5.4.*",
|
||||
"illuminate/routing": "5.4.*",
|
||||
"illuminate/session": "5.4.*",
|
||||
"illuminate/support": "5.4.*",
|
||||
"illuminate/view": "5.4.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/database": "5.2.*",
|
||||
"mockery/mockery": "~0.9",
|
||||
"phpunit/phpunit": "~4.0"
|
||||
"illuminate/database": "5.4.*",
|
||||
"mockery/mockery": "~0.9.4",
|
||||
"phpunit/phpunit": "~5.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -55,7 +55,7 @@ trait FormAccessible
|
||||
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||
|
||||
$mutator = collect($methods)
|
||||
->first(function ($index, ReflectionMethod $method) use ($key) {
|
||||
->first(function (ReflectionMethod $method) use ($key) {
|
||||
return $method->getName() == 'form' . Str::studly($key) . 'Attribute';
|
||||
});
|
||||
|
||||
|
||||
+9
-9
@@ -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('<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>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
|
||||
+14
-2
@@ -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.
|
||||
*
|
||||
@@ -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) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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('<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()
|
||||
@@ -301,12 +303,23 @@ 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()
|
||||
{
|
||||
$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 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()
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -39,6 +39,28 @@ 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