Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from ollietreend/issue-10
Browse files Browse the repository at this point in the history
Fixes #10 - URL decoding
  • Loading branch information
AD7six committed Mar 26, 2015
2 parents 3f33829 + 8f7a4e2 commit 69ff74a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Dsn.php
Expand Up @@ -239,6 +239,14 @@ protected function parseUrlArray($url)

$url = array_merge($this->uriKeys, $url);

foreach (['host', 'user', 'pass'] as $key) {
if (!isset($url[$key])) {
continue;
}

$url[$key] = urldecode($url[$key]);
}

foreach ($url as $key => $val) {
$setter = 'set' . ucfirst($key);
$this->$setter($val);
Expand Down Expand Up @@ -289,6 +297,14 @@ protected function toUrlArray($data)
{
$url = array_intersect_key($data, $this->uriKeys);

foreach (['host', 'user', 'pass'] as $key) {
if (!isset($url[$key])) {
continue;
}

$url[$key] = urlencode($url[$key]);
}

if ($url['adapter']) {
$return = $url['scheme'] . '+' . $url['adapter'] . '://';
} else {
Expand All @@ -315,7 +331,6 @@ protected function toUrlArray($data)
if ($query) {
foreach ($query as $key => &$value) {
if (is_array($value)) {

$intermediate = [];
foreach ($value as $k => $v) {
$v = urlencode($v);
Expand Down
15 changes: 15 additions & 0 deletions tests/TestCase/Wrapper/CakePHP/V2/EmailDsnTest.php
Expand Up @@ -73,6 +73,21 @@ public function defaultsProvider()
'layout' => false,
'timeout' => 30,
]
],
[
'smtp://user:secret@ssl%3A%2F%2Flocalhost:465/?from=you@localhost&messageId=1&template=0&layout=0&timeout=30',
[
'transport' => 'Smtp',
'host' => 'ssl://localhost',
'port' => 465,
'username' => 'user',
'password' => 'secret',
'from' => 'you@localhost',
'messageId' => true,
'template' => false,
'layout' => false,
'timeout' => 30,
]
]
];
}
Expand Down
15 changes: 15 additions & 0 deletions tests/TestCase/Wrapper/CakePHP/V3/EmailDsnTest.php
Expand Up @@ -79,6 +79,21 @@ public function defaultsProvider()
'layout' => false,
'timeout' => 30,
]
],
[
'smtp://user:secret@ssl%3A%2F%2Flocalhost:465/?from=you@localhost&messageId=1&template=0&layout=0&timeout=30',
[
'className' => 'Smtp',
'host' => 'ssl://localhost',
'port' => 465,
'username' => 'user',
'password' => 'secret',
'from' => 'you@localhost',
'messageId' => true,
'template' => false,
'layout' => false,
'timeout' => 30,
]
]
];
}
Expand Down

0 comments on commit 69ff74a

Please sign in to comment.