Skip to content

Commit bb03284

Browse files
committed
fixed queries with dots #101
1 parent 994f0bc commit bb03284

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

src/Url.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,18 +443,42 @@ protected function parseUrl($url)
443443
$this->info = parse_url($url);
444444

445445
if (isset($this->info['query'])) {
446-
parse_str($this->info['query'], $this->info['query']);
446+
$queryString = preg_replace_callback('/(^|(?<=&))[^=[&]+/', function ($key) {
447+
return bin2hex(urldecode($key[0]));
448+
}, $this->info['query']);
447449

448-
array_walk_recursive($this->info['query'], function (&$value) {
449-
$value = urldecode($value);
450-
});
450+
parse_str($queryString, $query);
451+
452+
$this->info['query'] = self::fixQuery($query);
451453
}
452454

453455
if (isset($this->info['path'])) {
454456
$this->setPath($this->info['path']);
455457
}
456458
}
457459

460+
/**
461+
* Fix query's key and values.
462+
*
463+
* @param array $query
464+
*
465+
* @return array
466+
*/
467+
private static function fixQuery(array $query)
468+
{
469+
$fixed = [];
470+
471+
foreach ($query as $key => $value) {
472+
if (is_array($value)) {
473+
$fixed[hex2bin($key)] = self::fixQuery($value);
474+
} else {
475+
$fixed[hex2bin($key)] = urldecode($value);
476+
}
477+
}
478+
479+
return $fixed;
480+
}
481+
458482
/**
459483
* Return an absolute url based in a relative.
460484
*

tests/MovimTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
class MovimTest extends TestCaseBase
4+
{
5+
public function testOne()
6+
{
7+
$this->assertEmbed(
8+
'https://nl.movim.eu/?node/blabla.movim.eu/random/1fb06a3cc05c4490bf659c227b39a9aa',
9+
[
10+
'title' => 'Paris Attacks, cat not giving a fuck',
11+
'description' => 'Can you find the cat?',
12+
'image' => 'http://hugelolcdn.com/i700/361973.jpg',
13+
]
14+
);
15+
}
16+
}

0 commit comments

Comments
 (0)