From 698cf8a02637d96308489e49437d7bbb4ff2fded Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 7 Dec 2024 18:16:40 +0100 Subject: [PATCH] Remove FixupMondeDiplomatiqueUriSubscriber --- app/config/services.yml | 1 - .../FixupMondeDiplomatiqueUriSubscriber.php | 33 ------- ...ixupMondeDiplomatiqueUriSubscriberTest.php | 95 ------------------- 3 files changed, 129 deletions(-) delete mode 100644 src/Guzzle/FixupMondeDiplomatiqueUriSubscriber.php delete mode 100644 tests/Guzzle/FixupMondeDiplomatiqueUriSubscriberTest.php diff --git a/app/config/services.yml b/app/config/services.yml index 0b4c91f8c..e23f459d8 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -219,7 +219,6 @@ services: Wallabag\Helper\HttpClientFactory: calls: - ['addSubscriber', ['@Wallabag\Guzzle\AuthenticatorSubscriber']] - - ['addSubscriber', ['@Wallabag\Guzzle\FixupMondeDiplomatiqueUriSubscriber']] RulerZ\RulerZ: alias: rulerz diff --git a/src/Guzzle/FixupMondeDiplomatiqueUriSubscriber.php b/src/Guzzle/FixupMondeDiplomatiqueUriSubscriber.php deleted file mode 100644 index 977eea785..000000000 --- a/src/Guzzle/FixupMondeDiplomatiqueUriSubscriber.php +++ /dev/null @@ -1,33 +0,0 @@ - [['fixUri', 500]]]; - } - - public function fixUri(CompleteEvent $event) - { - $response = $event->getResponse(); - - if (!$response->hasHeader('Location')) { - return; - } - - $uri = $response->getHeader('Location'); - if (false === ($badParameter = strstr($uri, 'retour=http://'))) { - return; - } - - $response->setHeader('Location', str_replace($badParameter, urlencode($badParameter), $uri)); - } -} diff --git a/tests/Guzzle/FixupMondeDiplomatiqueUriSubscriberTest.php b/tests/Guzzle/FixupMondeDiplomatiqueUriSubscriberTest.php deleted file mode 100644 index 43c1049e0..000000000 --- a/tests/Guzzle/FixupMondeDiplomatiqueUriSubscriberTest.php +++ /dev/null @@ -1,95 +0,0 @@ -getEvents(); - - $this->assertArrayHasKey('complete', $events); - $this->assertCount(2, $events['complete'][0]); - } - - public function testGetEventsWithoutHeaderLocation() - { - $response = new Response( - 200, - [ - 'content-type' => 'text/html', - ], - Stream::factory('') - ); - - $event = $this->getMockBuilder(CompleteEvent::class) - ->disableOriginalConstructor() - ->getMock(); - - $event->expects($this->once()) - ->method('getResponse') - ->willReturn($response); - - $subscriber = new FixupMondeDiplomatiqueUriSubscriber(); - $subscriber->fixUri($event); - - $this->assertFalse($response->hasHeader('Location')); - } - - public function testGetEventsWithNotMachingHeaderLocation() - { - $response = new Response( - 200, - [ - 'content-type' => 'text/html', - 'Location' => 'http://example.com', - ], - Stream::factory('') - ); - - $event = $this->getMockBuilder(CompleteEvent::class) - ->disableOriginalConstructor() - ->getMock(); - - $event->expects($this->once()) - ->method('getResponse') - ->willReturn($response); - - $subscriber = new FixupMondeDiplomatiqueUriSubscriber(); - $subscriber->fixUri($event); - - $this->assertSame('http://example.com', $response->getHeader('Location')); - } - - public function testGetEventsWithMachingHeaderLocation() - { - $response = new Response( - 200, - [ - 'content-type' => 'text/html', - 'Location' => 'http://example.com/?foo=bar&retour=http://example.com', - ], - Stream::factory('') - ); - - $event = $this->getMockBuilder(CompleteEvent::class) - ->disableOriginalConstructor() - ->getMock(); - - $event->expects($this->once()) - ->method('getResponse') - ->willReturn($response); - - $subscriber = new FixupMondeDiplomatiqueUriSubscriber(); - $subscriber->fixUri($event); - - $this->assertSame('http://example.com/?foo=bar&retour%3Dhttp%3A%2F%2Fexample.com', $response->getHeader('Location')); - } -}