summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-01-14 13:44:57 -0500
committerFrederic Guillot <fred@kanboard.net>2017-01-14 13:44:57 -0500
commit2cac4c811d5e7f278d4fa24239cda47b984f15ca (patch)
tree7ff199655d73e62d6490ada482f9db0413f1e212
parentfe1629e3ea1931d1075adbdc3e1d7d11e51b44ac (diff)
Add workaround when IE11 submit corrupted multipart/form-data
-rw-r--r--app/Core/Http/Request.php15
-rw-r--r--tests/units/Core/Http/RequestTest.php3
2 files changed, 17 insertions, 1 deletions
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index 2e84958d..44bfdbe6 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -105,7 +105,7 @@ class Request extends Base
{
if (! empty($this->post) && ! empty($this->post['csrf_token']) && $this->token->validateCSRFToken($this->post['csrf_token'])) {
unset($this->post['csrf_token']);
- return $this->post;
+ return $this->filterValues($this->post);
}
return array();
@@ -344,4 +344,17 @@ class Request extends Base
{
return isset($this->server[$variable]) ? $this->server[$variable] : '';
}
+
+ protected function filterValues(array $values)
+ {
+ foreach ($values as $key => $value) {
+
+ // IE11 Workaround when submitting multipart/form-data
+ if (strpos($key, '-----------------------------') === 0) {
+ unset($values[$key]);
+ }
+ }
+
+ return $values;
+ }
}
diff --git a/tests/units/Core/Http/RequestTest.php b/tests/units/Core/Http/RequestTest.php
index 1db0100c..697c3c0f 100644
--- a/tests/units/Core/Http/RequestTest.php
+++ b/tests/units/Core/Http/RequestTest.php
@@ -43,6 +43,9 @@ class RequestTest extends Base
$request = new Request($this->container, array(), array(), array('myvar' => 'myvalue', 'csrf_token' => $this->container['token']->getCSRFToken()), array(), array());
$this->assertEquals(array('myvar' => 'myvalue'), $request->getValues());
+
+ $request = new Request($this->container, array(), array(), array('myvar' => 'myvalue', '-----------------------------7e1c32510025c--' => '', 'csrf_token' => $this->container['token']->getCSRFToken()), array(), array());
+ $this->assertEquals(array('myvar' => 'myvalue'), $request->getValues());
}
public function testGetFileContent()