Skip to content

Commit 4da4f50

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Serializer] Fixed serialize and denormalize return types Run intl-data tests on resources change [Notifier] Add exception for deprecated slack dsn [FrameworkBundle] fix preserving some special chars in the query string when redirecting [HttpFoundation] fix parsing some special chars with HeaderUtils::parseQuery()
2 parents 8fa2954 + fd34c9c commit 4da4f50

File tree

9 files changed

+90
-13
lines changed

9 files changed

+90
-13
lines changed

.github/workflows/intl-data-tests.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Intl data tests
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/Symfony/Component/Intl/Resources/data/**'
7+
pull_request:
8+
paths:
9+
- 'src/Symfony/Component/Intl/Resources/data/**'
10+
11+
jobs:
12+
13+
tests:
14+
name: Tests (intl-data)
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Define the ICU version
22+
run: |
23+
SYMFONY_ICU_VERSION=$(php -r 'require "src/Symfony/Component/Intl/Intl.php"; echo Symfony\Component\Intl\Intl::getIcuStubVersion();')
24+
echo "SYMFONY_ICU_VERSION=$SYMFONY_ICU_VERSION" >> $GITHUB_ENV
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
coverage: "none"
30+
extensions: "zip,intl-${{env.SYMFONY_ICU_VERSION}}"
31+
ini-values: "memory_limit=-1"
32+
php-version: "7.4"
33+
34+
- name: Install dependencies
35+
run: |
36+
echo "::group::composer update"
37+
composer update --no-progress --no-suggest --ansi
38+
echo "::endgroup::"
39+
echo "::group::install phpunit"
40+
./phpunit install
41+
echo "::endgroup::"
42+
43+
- name: Report the ICU version
44+
run: icu-config --version && php -i | grep 'ICU version'
45+
46+
- name: Run intl-data tests
47+
run: ./phpunit --group intl-data -v

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,19 @@ public function testRedirectWithQuery()
302302
$baseUrl = '/base';
303303
$port = 80;
304304

305-
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza');
305+
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza&f[%2525][%26][%3D][p.c]=d');
306306
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
307307
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
308-
$urlGenerator->expects($this->exactly(2))->method('generate')->willReturn('/test?b.se=zaza&base2=zaza')->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
308+
$urlGenerator->expects($this->exactly(2))
309+
->method('generate')
310+
->willReturn('/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d')
311+
->with('/test', ['b.se' => 'zaza', 'base2' => 'zaza', 'f' => ['%25' => ['&' => ['=' => ['p.c' => 'd']]]]], UrlGeneratorInterface::ABSOLUTE_URL);
309312

310313
$controller = new RedirectController($urlGenerator);
311-
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza');
314+
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d');
312315

313316
$request->attributes->set('_route_params', ['base2' => 'zaza', 'route' => '/test', 'ignoreAttributes' => false, 'keepRequestMethod' => false, 'keepQueryParams' => true]);
314-
$this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza');
317+
$this->assertRedirectUrl($controller($request), '/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d');
315318
}
316319

317320
public function testRedirectWithQueryWithRouteParamsOveriding()

src/Symfony/Component/HttpFoundation/HeaderUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static function parseQuery(string $query, bool $ignoreBrackets = false, s
228228
if (false === $i = strpos($k, '[')) {
229229
$q[] = bin2hex($k).$v;
230230
} else {
231-
$q[] = substr_replace($k, bin2hex(substr($k, 0, $i)), 0, $i).$v;
231+
$q[] = bin2hex(substr($k, 0, $i)).rawurlencode(substr($k, $i)).$v;
232232
}
233233
}
234234

src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public function provideParseQuery()
151151
['a[b]=c', 'a%5Bb%5D=c'],
152152
['a[b][c.d]=c', 'a%5Bb%5D%5Bc.d%5D=c'],
153153
['a%5Bb%5D=c'],
154+
['f[%2525][%26][%3D][p.c]=d', 'f%5B%2525%5D%5B%26%5D%5B%3D%5D%5Bp.c%5D=d'],
154155
];
155156
}
156157

src/Symfony/Component/Notifier/Bridge/Slack/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ Slack Notifier
33

44
Provides Slack integration for Symfony Notifier.
55

6+
DSN example
7+
-----------
8+
9+
```
10+
// .env file
11+
SLACK_DSN=slack://TOKEN@default?channel=CHANNEL
12+
```
13+
14+
where:
15+
- `TOKEN` is your Bot User OAuth Access Token
16+
- `CHANNEL` is a Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name
17+
618
Resources
719
---------
820

src/Symfony/Component/Notifier/Bridge/Slack/SlackTransportFactory.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Slack;
1313

14+
use Symfony\Component\Notifier\Exception\IncompleteDsnException;
1415
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1516
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1617
use Symfony\Component\Notifier\Transport\Dsn;
@@ -28,17 +29,20 @@ final class SlackTransportFactory extends AbstractTransportFactory
2829
*/
2930
public function create(Dsn $dsn): TransportInterface
3031
{
31-
$scheme = $dsn->getScheme();
32+
if ('slack' !== $dsn->getScheme()) {
33+
throw new UnsupportedSchemeException($dsn, 'slack', $this->getSupportedSchemes());
34+
}
35+
36+
if ('/' !== $dsn->getPath()) {
37+
throw new IncompleteDsnException('Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven\'t updated the DSN when upgrading from 5.1).');
38+
}
39+
3240
$accessToken = $this->getUser($dsn);
3341
$channel = $dsn->getOption('channel');
3442
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
3543
$port = $dsn->getPort();
3644

37-
if ('slack' === $scheme) {
38-
return (new SlackTransport($accessToken, $channel, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
39-
}
40-
41-
throw new UnsupportedSchemeException($dsn, 'slack', $this->getSupportedSchemes());
45+
return (new SlackTransport($accessToken, $channel, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
4246
}
4347

4448
protected function getSupportedSchemes(): array

src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportFactoryTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Notifier\Bridge\Slack\SlackTransportFactory;
1616
use Symfony\Component\Notifier\Exception\IncompleteDsnException;
17+
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
1718
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1819
use Symfony\Component\Notifier\Transport\Dsn;
1920

@@ -30,6 +31,15 @@ public function testCreateWithDsn(): void
3031
$this->assertSame(sprintf('slack://%s?channel=%s', $host, $channel), (string) $transport);
3132
}
3233

34+
public function testCreateWithDeprecatedDsn(): void
35+
{
36+
$this->expectException(InvalidArgumentException::class);
37+
$this->expectExceptionMessage('Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven\'t updated the DSN when upgrading from 5.1).');
38+
39+
$factory = new SlackTransportFactory();
40+
$factory->create(Dsn::fromString('slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'));
41+
}
42+
3343
public function testCreateWithNoTokenThrowsMalformed(): void
3444
{
3545
$factory = new SlackTransportFactory();

src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface DenormalizerInterface
3232
* @param string $format Format the given data was extracted from
3333
* @param array $context Options available to the denormalizer
3434
*
35-
* @return object|array
35+
* @return mixed
3636
*
3737
* @throws BadMethodCallException Occurs when the normalizer is not called in an expected context
3838
* @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported

src/Symfony/Component/Serializer/SerializerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function serialize($data, string $format, array $context = []);
3232
*
3333
* @param mixed $data
3434
*
35-
* @return object|array
35+
* @return mixed
3636
*/
3737
public function deserialize($data, string $type, string $format, array $context = []);
3838
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy