Skip to content

Commit 07dca92

Browse files
toin0uwilldurand
authored andcommitted
fix encoding issue for maxmind provider
1 parent 26c3bb6 commit 07dca92

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/Geocoder/Provider/MaxMindProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function executeQuery($query)
139139
$data['country'] = $this->countryCodeToCountryName($data['countryCode']);
140140
}
141141

142-
return array(array_merge($this->getDefaults(), $data));
142+
return array($this->fixEncoding(array_merge($this->getDefaults(), $data)));
143143
}
144144

145145
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:215:"BR,Brazil,26,"Santa Catarina",Florian�polis,-27.5833,-48.5667,,,America/Sao_Paulo,SA,,"Global Village Telecom","Global Village Telecom",gvt.net.br,"AS18881 Global Village Telecom",Cable/DSL,residential,18,99,52,92,,";

tests/Geocoder/Tests/Provider/MaxMindProviderTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,38 @@ public function testGetGeocodedDataOmniServiceWithRealIPv4()
369369
$this->assertEquals('America/Chicago', $result['timezone']);
370370
}
371371

372+
public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding()
373+
{
374+
if (!isset($_SERVER['MAXMIND_API_KEY'])) {
375+
$this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
376+
}
377+
378+
$provider = new MaxMindProvider($this->getAdapter(), $_SERVER['MAXMIND_API_KEY'],
379+
MaxMindProvider::OMNI_SERVICE, true);
380+
$result = $provider->getGeocodedData('189.26.128.80');
381+
382+
$this->assertInternalType('array', $result);
383+
$this->assertCount(1, $result);
384+
385+
$result = $result[0];
386+
$this->assertInternalType('array', $result);
387+
$this->assertEquals(-27.5833, $result['latitude'], '', 0.1);
388+
$this->assertEquals(-48.5666, $result['longitude'], '', 0.1);
389+
$this->assertEquals('Florianópolis', $result['city']);
390+
$this->assertNull($result['zipcode']);
391+
$this->assertEquals('26', $result['regionCode']);
392+
$this->assertEquals('Brazil', $result['country']);
393+
$this->assertEquals('BR', $result['countryCode']);
394+
$this->assertNull($result['bounds']);
395+
$this->assertNull($result['streetNumber']);
396+
$this->assertNull($result['streetName']);
397+
$this->assertNull($result['cityDistrict']);
398+
$this->assertNull($result['county']);
399+
$this->assertNull($result['countyCode']);
400+
$this->assertEquals('Santa Catarina', $result['region']);
401+
$this->assertEquals('America/Sao_Paulo', $result['timezone']);
402+
}
403+
372404
public function testGetGeocodedDataWithRealIPv6()
373405
{
374406
if (!isset($_SERVER['MAXMIND_API_KEY'])) {

0 commit comments

Comments
 (0)