Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 66a46f0

Browse filesBrowse files
committed
Merge branch '5.0'
* 5.0: [HttpClient] Fix typo [Mime] Fix boundary header ignore microseconds submitted by Edge
2 parents ade47dd + c9cdf93 commit 66a46f0
Copy full SHA for 66a46f0

File tree

7 files changed

+77
-15
lines changed
Filter options

7 files changed

+77
-15
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/TimeType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
+13-11Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6161
}
6262

6363
if ('single_text' === $options['widget']) {
64-
// handle seconds ignored by user's browser when with_seconds enabled
65-
// https://codereview.chromium.org/450533009/
66-
if ($options['with_seconds']) {
67-
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) {
68-
$data = $e->getData();
69-
if ($data && preg_match('/^\d{2}:\d{2}$/', $data)) {
70-
$e->setData($data.':00');
64+
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
65+
66+
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) use ($options) {
67+
$data = $e->getData();
68+
if ($data && preg_match('/^(?P<hours>\d{2}):(?P<minutes>\d{2})(?::(?P<seconds>\d{2})(?:\.\d+)?)?$/', $data, $matches)) {
69+
if ($options['with_seconds']) {
70+
// handle seconds ignored by user's browser when with_seconds enabled
71+
// https://codereview.chromium.org/450533009/
72+
$e->setData(sprintf('%s:%s:%s', $matches['hours'], $matches['minutes'], isset($matches['seconds']) ? $matches['seconds'] : '00'));
73+
} else {
74+
$e->setData(sprintf('%s:%s', $matches['hours'], $matches['minutes']));
7175
}
72-
});
73-
}
76+
}
77+
});
7478

7579
if (null !== $options['reference_date']) {
7680
$format = 'Y-m-d '.$format;
@@ -83,8 +87,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
8387
}
8488
});
8589
}
86-
87-
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
8890
} else {
8991
$hourOptions = $minuteOptions = $secondOptions = [
9092
'error_bubbling' => true,

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,54 @@ public function testSubmitDifferentTimezonesDuringDaylightSavingTimeUsingSingleT
328328
$this->assertSame('14:09:10', $form->getData()->format('H:i:s'));
329329
}
330330

331+
public function testSubmitWithoutSecondsAndBrowserAddingSeconds()
332+
{
333+
$form = $this->factory->create(static::TESTED_TYPE, null, [
334+
'model_timezone' => 'UTC',
335+
'view_timezone' => 'UTC',
336+
'input' => 'string',
337+
'widget' => 'single_text',
338+
'with_seconds' => false,
339+
]);
340+
341+
$form->submit('03:04:00');
342+
343+
$this->assertEquals('03:04:00', $form->getData());
344+
$this->assertEquals('03:04', $form->getViewData());
345+
}
346+
347+
public function testSubmitWithSecondsAndBrowserAddingMicroseconds()
348+
{
349+
$form = $this->factory->create(static::TESTED_TYPE, null, [
350+
'model_timezone' => 'UTC',
351+
'view_timezone' => 'UTC',
352+
'input' => 'string',
353+
'widget' => 'single_text',
354+
'with_seconds' => true,
355+
]);
356+
357+
$form->submit('03:04:00.000');
358+
359+
$this->assertEquals('03:04:00', $form->getData());
360+
$this->assertEquals('03:04:00', $form->getViewData());
361+
}
362+
363+
public function testSubmitWithoutSecondsAndBrowserAddingMicroseconds()
364+
{
365+
$form = $this->factory->create(static::TESTED_TYPE, null, [
366+
'model_timezone' => 'UTC',
367+
'view_timezone' => 'UTC',
368+
'input' => 'string',
369+
'widget' => 'single_text',
370+
'with_seconds' => false,
371+
]);
372+
373+
$form->submit('03:04:00.000');
374+
375+
$this->assertEquals('03:04:00', $form->getData());
376+
$this->assertEquals('03:04', $form->getViewData());
377+
}
378+
331379
public function testSetDataWithoutMinutes()
332380
{
333381
$form = $this->factory->create(static::TESTED_TYPE, null, [

‎src/Symfony/Component/HttpClient/CurlHttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/CurlHttpClient.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
5353
private static $curlVersion;
5454

5555
/**
56-
* @param array $defaultOptions Default requests' options
56+
* @param array $defaultOptions Default request's options
5757
* @param int $maxHostConnections The maximum number of connections to a single host
5858
* @param int $maxPendingPushes The maximum number of pushed responses to accept in the queue
5959
*

‎src/Symfony/Component/HttpClient/HttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/HttpClient.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
final class HttpClient
2222
{
2323
/**
24-
* @param array $defaultOptions Default requests' options
24+
* @param array $defaultOptions Default request's options
2525
* @param int $maxHostConnections The maximum number of connections to a single host
2626
* @param int $maxPendingPushes The maximum number of pushed responses to accept in the queue
2727
*

‎src/Symfony/Component/HttpClient/NativeHttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/NativeHttpClient.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
4141
private $multi;
4242

4343
/**
44-
* @param array $defaultOptions Default requests' options
44+
* @param array $defaultOptions Default request's options
4545
* @param int $maxHostConnections The maximum number of connections to open
4646
*
4747
* @see HttpClientInterface::OPTIONS_DEFAULTS for available options

‎src/Symfony/Component/Mime/Part/AbstractMultipartPart.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Part/AbstractMultipartPart.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function asDebugString(): string
9191
private function getBoundary(): string
9292
{
9393
if (null === $this->boundary) {
94-
$this->boundary = '_=_symfony_'.time().'_'.bin2hex(random_bytes(16)).'_=_';
94+
$this->boundary = strtr(base64_encode(random_bytes(6)), '+/', '-_');
9595
}
9696

9797
return $this->boundary;

‎src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,16 @@ public function testContentLineLength()
9191
$this->assertEquals($foo, $parts[0]->bodyToString());
9292
$this->assertEquals($bar, $parts[1]->bodyToString());
9393
}
94+
95+
public function testBoundaryContentTypeHeader()
96+
{
97+
$f = new FormDataPart([
98+
'file' => new DataPart('data.csv', 'data.csv', 'text/csv'),
99+
]);
100+
$headers = $f->getPreparedHeaders()->toArray();
101+
$this->assertRegExp(
102+
'/^Content-Type: multipart\/form-data; boundary=[a-zA-Z0-9\-_]{8}$/',
103+
$headers[0]
104+
);
105+
}
94106
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.