Skip to content

Commit 97330bc

Browse files
committed
do not fix multidimensional arrays
1 parent 9c7035e commit 97330bc

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

src/Url.php

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -442,43 +442,32 @@ protected function parseUrl($url)
442442

443443
$this->info = parse_url($url);
444444

445+
if (isset($this->info['path'])) {
446+
$this->setPath($this->info['path']);
447+
}
448+
445449
if (empty($this->info['query'])) {
446450
$this->info['query'] = [];
447-
} else {
448-
$queryString = preg_replace_callback('/(^|(?<=&))[^=[&]+/', function ($key) {
449-
return base64_encode(urldecode($key[0]));
450-
}, $this->info['query']);
451-
452-
parse_str($queryString, $query);
453-
454-
$this->info['query'] = $query ? self::fixQuery($query) : [];
451+
return;
455452
}
456453

457-
if (isset($this->info['path'])) {
458-
$this->setPath($this->info['path']);
459-
}
460-
}
454+
// Fix dots and other characters used in query's variables names
455+
// https://github.com/oscarotero/Embed/issues/101
456+
$queryString = preg_replace_callback('/(^|(?<=&))[^=[&]+/', function ($key) {
457+
return bin2hex(urldecode($key[0]));
458+
}, $this->info['query']);
461459

462-
/**
463-
* Fix query's key and values.
464-
*
465-
* @param array $query
466-
*
467-
* @return array
468-
*/
469-
private static function fixQuery(array $query)
470-
{
471-
$fixed = [];
460+
parse_str($queryString, $query);
472461

473-
foreach ($query as $key => $value) {
474-
if (is_array($value)) {
475-
$fixed[base64_decode($key)] = self::fixQuery($value);
476-
} else {
477-
$fixed[base64_decode($key)] = urldecode($value);
478-
}
462+
$this->info['query'] = (array) $query;
463+
464+
foreach ($this->info['query'] as $key => $value) {
465+
$fixed[hex2bin($key)] = $value;
479466
}
480467

481-
return $fixed;
468+
array_walk_recursive($this->info['query'], function (&$value) {
469+
$value = urldecode($value);
470+
});
482471
}
483472

484473
/**

0 commit comments

Comments
 (0)